Compare commits

...

1631 Commits
v5.0 ... master

Author SHA1 Message Date
Jia Tan af071ef770 Docs: Simplify SECURITY.md. 2024-03-26 03:38:12 +08:00
Lasse Collin 0b99783d63 liblzma: memcmplen.h: Add a comment why subtraction is used. 2024-03-22 17:46:30 +02:00
Lasse Collin 8a25ba024d INSTALL: Document arguments of --enable-symbol-versions. 2024-03-15 18:04:10 +02:00
Lasse Collin 49324b711f Build: Use only the generic symbol versioning with NVIDIA HPC Compiler.
This does the previous commit with CMake.

AC_EGREP_CPP uses AC_REQUIRE so the outermost if-commands must
be changed to AS_IF to ensure that things wont break some day.
See 5a5bd7f871.
2024-03-15 18:04:10 +02:00
Lasse Collin c273123ed0 CMake: Use only the generic symbol versioning with NVIDIA HPC Compiler.
It doesn't support the __symver__ attribute or __asm__(".symver ...").
The generic symbol versioning can still be used since it only needs
linker support.
2024-03-15 18:04:10 +02:00
Lasse Collin df7f487648 Update THANKS. 2024-03-15 18:04:10 +02:00
Lasse Collin 3217b82b3e liblzma: Minor comment edits. 2024-03-15 18:03:47 +02:00
Sergey Kosukhin 096bc0e3f8 liblzma: Fix building with NVHPC (NVIDIA HPC SDK).
NVHPC compiler has several issues that make it impossible to
build liblzma:
  - the compiler cannot handle unions that contain pointers that
    are not the first members;
  - the compiler cannot handle the assembler code in range_decoder.h
    (LZMA_RANGE_DECODER_CONFIG has to be set to zero);
  - the compiler fails to produce valid code for delta_decode if the
    vectorization is enabled, which results in failed tests.

This introduces NVHPC-specific workarounds that address the issues.
2024-03-15 17:30:50 +02:00
Lasse Collin 2ad7fad670 CMake: Disable symbol versioning on non-glibc Linux.
This better matches what configure.ac does. For example, musl has
only basic symbol versioning support:

https://wiki.musl-libc.org/functional-differences-from-glibc.html#Symbol_versioning

configure.ac tries to enable symbol versioning only with glibc
so now CMake does the same.
2024-03-15 17:30:50 +02:00
Lasse Collin 82f0c0d39e CMake: Make symbol versioning configurable. 2024-03-15 17:30:50 +02:00
Lasse Collin 45d33bfc45 Build: Style tweaks to configure.ac.
The AC_MSG_ERROR line is overlong anyway as are a few other
AC_MSG_ERROR lines already.
2024-03-13 22:00:23 +02:00
Sergey Kosukhin f56ed6fac6 Build: Let the users override the symbol versioning variant.
There are cases when the users want to decide themselves whether
they want to have the generic (even on GNU/Linux) or the linux
(even if we do not recommend that) symbol versioning variant.
The former might be needed to circumvent compiler issues (i.e.
the compiler does not support all features that are required
for the linux versioning), the latter might help in overriding
the assumptions made in the configure script.
2024-03-13 21:59:55 +02:00
Jia Tan a4f2e20d84 Add NEWS for 5.6.1 2024-03-09 11:27:27 +08:00
Jia Tan f01be8ad75 Translations: Add missing --riscv option to man page translations. 2024-03-09 10:43:20 +08:00
Jia Tan 6e636819e8 Tests: Update two test files.
The original files were generated with random local to my machine.
To better reproduce these files in the future, a constant seed was used
to recreate these files.
2024-03-09 10:18:29 +08:00
Jia Tan a3a29bbd5d Tests: Test --single-stream can decompress bad-3-corrupt_lzma2.xz.
The first stream in this file is valid, so this tests that xz properly
stops after decompressing it.
2024-03-09 10:08:32 +08:00
Jia Tan 0b4ccc9145 Tests: Update RISC-V test files.
This increases code coverage and tests for possible shifting bugs.
2024-03-09 10:05:32 +08:00
Jia Tan 8c9b8b2063 liblzma: Fix typos in crc32_fast.c and crc64_fast.c. 2024-03-09 09:52:32 +08:00
Jia Tan b93a8d7631 Tests: Replace HAVE_MICROLZMA usage in CMake and Autotools builds.
This reverts commit adaacafde6.
2024-03-09 09:49:55 +08:00
Jia Tan 82ecc53819 liblzma: Fix false Valgrind error report with GCC.
With GCC and a certain combination of flags, Valgrind will falsely
trigger an invalid write. This appears to be due to the omission of
instructions to properly save, set up, and restore the frame pointer.

The IFUNC resolver is a leaf function since it only calls a function
that is inlined. So sometimes GCC omits the frame pointer instructions
in the resolver unless this optimization is explictly disabled.

This fixes https://bugzilla.redhat.com/show_bug.cgi?id=2267598.
2024-03-09 09:20:57 +08:00
Lasse Collin 3007e74ef2 liblzma: Fix a typo in a comment in the RISC-V filter. 2024-03-05 23:23:16 +02:00
Jia Tan 72d2933bfa liblzma: Use attribute no_profile_instrument_function with ifunc.
Thanks to Sam James for determining this was the attribute needed to
workaround the GCC bug and for his version of the patch in Gentoo.
2024-03-05 01:54:30 +08:00
Jia Tan e5faaebbcf Build: Require attribute no_profile_instrument_function for ifunc usage.
Using __attribute__((__no_profile_instrument_function__)) on the ifunc
resolver works around a bug in GCC -fprofile-generate:
it adds profiling code even to ifunc resolvers which can make
the ifunc resolver crash at program startup. This attribute
was not introduced until GCC 7 and Clang 13, so ifunc won't
be used with prior versions of these compilers.

This bug was brought to our attention by:

    https://bugs.gentoo.org/925415

And was reported to upstream GCC by:

    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11411
2024-03-05 01:54:30 +08:00
Lasse Collin 7eeadd279a liblzma: Fix a comment in the RISC-V filter. 2024-03-04 19:23:18 +02:00
Lasse Collin 5f3d059529 CMake: Warn if translated man pages are missing. 2024-02-29 16:37:19 +02:00
Lasse Collin 4cd1042ee7 CMake: Warn if gettext tools and pre-created .gmo files are missing.
It's only done with CMake >= 3.20 and if library support
for translation was already found.

Sort of fixes: https://github.com/tukaani-project/xz/issues/82
2024-02-29 16:37:19 +02:00
Lasse Collin a94b42362c xz: Add comments. 2024-02-28 18:26:25 +02:00
Jia Tan bbf112e323 xz: Change logging level for thread reduction to highest verbosity only.
Now that multi threaded encoding is the default, users do not need to
see a warning message everytime the number of threads is reduced. On
some machines, this could happen very often. It is not unreasonable for
users to need to set double verbose mode to see this kind of
information.

To see these warning messages -vv or --verbose --verbose must be passed
to set xz into the highest possible verbosity mode.

These warnings had caused automated testing frameworks to fail when they
expected no output to stderr.

Thanks to Sebastian Andrzej Siewior for reporting this and for the
initial version of the patch.
2024-02-29 00:05:50 +08:00
Lasse Collin 649f644744 Fix sorting in THANKS. 2024-02-26 23:06:13 +02:00
Jia Tan 1255b7d849 Update THANKS. 2024-02-26 23:40:50 +08:00
Chien Wong eee579fff5 xz: Add missing RISC-V on the filter list in the man page
Signed-off-by: Chien Wong <m@xv97.com>
2024-02-26 23:36:04 +08:00
Jia Tan 328c52da8a Build: Fix Linux Landlock feature test in Autotools and CMake builds.
The previous Linux Landlock feature test assumed that having the
linux/landlock.h header file was enough. The new feature tests also
requires that prctl() and the required Landlock system calls are
supported.
2024-02-26 23:27:44 +08:00
Jia Tan eb8ad59e9b Tests: Add test_microlzma to .gitignore and CMakeLists.txt. 2024-02-26 20:06:10 +08:00
Jia Tan 9eed1b9a3a Tests: Correct license header in test_microlzma.c. 2024-02-26 19:56:25 +08:00
Jia Tan 8bf9f72ee1 Fix typos in NEWS and CMakeLists. 2024-02-25 21:41:55 +08:00
Jia Tan 5d8d915ebe Bump version and soname for 5.7.0alpha.
Like 5.5.0alpha, 5.7.0alpha won't be released, it's just to mark that
the branch is not stable.

Once again there is no API/ABI stability for new features in devel
versions. The major soname won't be bumped even if API/ABI of new
features breaks between devel releases.
2024-02-24 16:30:06 +08:00
Jia Tan a18fb1edef Add NEWS for 5.6.0. 2024-02-24 15:50:36 +08:00
Jia Tan 24355c5280 Translations: Remove obsolete and fuzzy matches from some translations.
The French and Brazilian Portuguese man page translations have not been
updated since the switch from public domain to 0BSD. The old GPLv2
strings have now been removed from these files.
2024-02-22 22:27:01 +08:00
Jia Tan 02ca4a7d7b Translations: Patch man pages to avoid fuzzy matches.
This will be fixed in the next round of translations, but this avoids
having a fuzzy match or not fixing the English version.
2024-02-21 00:31:54 +08:00
Jia Tan 898aad9fc7 xzmore: Fix typo in xzmore.1.
Thanks to Yuri Chornoivan.
2024-02-21 00:30:43 +08:00
Jia Tan 5631aa206c Translations: Update the Vietnamese translation. 2024-02-24 12:12:16 +08:00
Jia Tan a65fd7ce9d Translations: Update the Esperanto translation. 2024-02-24 12:06:40 +08:00
Jia Tan cf44e4b7f5 Tests: Add a few test files. 2024-02-23 23:09:59 +08:00
Jia Tan 39f4a1a86a Tests: Add MicroLZMA test. 2024-02-23 20:58:36 +08:00
Jia Tan adaacafde6 Build: Define HAVE_MICROLZMA when it is configured. 2024-02-23 20:57:59 +08:00
Jia Tan eea78216d2 xz: Fix Capsicum sandbox compile error.
user_abort_pipe[] was still being used instead of the parameters.
2024-02-23 20:27:15 +08:00
Jia Tan 32b0a3ce19 Build: Fix ARM64 CRC32 instruction feature test.
Old versions of Clang reported the unsupported function attribute and
__crc32d() function as warnings instead of errors, so the feature test
passed when it shouldn't have, causing a compile error at build time.
-Werror was added to this feature test to fix this. The change is not
needed for CMake because check_c_source_compiles() also performs
linking and the error is caught then.

Thanks to Sebastian Andrzej Siewior for reporting this.
2024-02-23 16:12:32 +08:00
Lasse Collin 4c81c9611f CMake: Add LOCALEDIR to the windres workaround.
LOCALEDIR may contain spaces like in "C:\Program Files".
2024-02-22 19:16:35 +02:00
Lasse Collin de4337fd89 xz: Landlock: Fix error message if input file is a directory.
If xz is given a directory, it should look like this:

    $ xz /usr/bin
    xz: /usr/bin: Is a directory, skipping

The Landlock rules didn't allow opening directories for reading:

    $ xz /usr/bin
    xz: /usr/bin: Permission denied

The simplest fix was to allow opening directories for reading.
While it's a bit silly to allow it solely for the error message,
it shouldn't make the sandbox significantly weaker.

The single-file use case (like when called from GNU tar) is
still as strict as possible: all Landlock restrictions are
enabled before (de)compression starts.
2024-02-22 15:18:25 +02:00
Lasse Collin 120da10ae1 liblzma: Disable branchless C version in range decoder.
Thanks to Sebastian Andrzej Siewior and Sam James for
benchmarking on various systems.
2024-02-22 14:41:29 +02:00
Lasse Collin 00440f52be INSTALL: Clarify that --disable-assembler affects only 32-bit x86. 2024-02-21 17:41:32 +02:00
Lasse Collin 11405be84e Windows: build.bash: Include COPYING.0BSD in the package. 2024-02-21 16:57:20 +02:00
Lasse Collin c27cf64e3e Windows: build.bash: include liblzma-crt-mixing.txt in the package. 2024-02-21 16:57:20 +02:00
Lasse Collin 8d38941bae Windows: Major update to Windows build instructions. 2024-02-21 16:57:20 +02:00
Lasse Collin 4b5b0d3523 Windows: Update windows/README-Windows.txt.
It's for binary packages built with windows/build.bash.
2024-02-21 16:57:20 +02:00
Lasse Collin 1ee716f740 Windows: Update windows/build.bash.
Support for the old MinGW was dropped. Only MinGW-w64 with GCC
is supported now.

The script now supports also cross-compilation from GNU/Linux
(tests are not run). MSYS2 and also the old MSYS 1.0.11 work
for building on Windows. The i686 and x86_64 toolchains must
be in PATH to build both 32-bit and 64-bit versions.

Parallel builds are done if "nproc" from GNU coreutils is available.

MinGW-w64 runtime copyright information file was renamed from
COPYING-Windows.txt to COPYING.MinGW-w64-runtime.txt which
is the filename used by MinGW-w64 itself. Its existence
is now mandatory, it's checked at the beginning of the script.

The file TODO is no longer copied to the package.
2024-02-20 21:04:29 +02:00
Jia Tan 60462e4260 Translations: Update the Romanian man page translations. 2024-02-20 23:32:22 +08:00
Jia Tan 10d733e5b8 Translations: Update the Korean man page translations. 2024-02-20 23:30:25 +08:00
Jia Tan 797a34b72a Translations: Update the Spanish translation. 2024-02-20 21:03:53 +08:00
Jia Tan 5c3751d019 Translations: Update the Romanian translation. 2024-02-20 20:18:07 +08:00
Jia Tan e2d31154ec Translations: Update the Croatian translation. 2024-02-20 20:15:50 +08:00
Jia Tan 704500f994 Translations: Update the German man page translations. 2024-02-20 20:05:44 +08:00
Jia Tan 1cfd3dca3f Translations: Update the German translation. 2024-02-20 19:58:25 +08:00
Jia Tan 28b9b3f16c Translations: Update the Hungarian translation. 2024-02-20 19:56:52 +08:00
Lasse Collin 00b06cd0af CMake: Fix building of lzmainfo when translations are enabled. 2024-02-19 16:48:18 +02:00
Lasse Collin b0d1422b60 CMake: Don't assume that -fvisibility=hidden is supported outside Windows.
The original code was good enough for supporting GNU/Linux
and a few others but it wasn't very portable.

CMake doesn't support Solaris Studio's -xldscope=hidden.
If it ever does, things should still work with this commit
as Solaris Studio supports not only its own __global but also
the GNU C __attribute__((visibility("default"))). Support for the
attribute was added in 2007 to Sun Studio 12 compiler version 5.9.
2024-02-19 16:28:49 +02:00
Lasse Collin 2ced9d34be CMake: Revise the component splitting. 2024-02-19 16:28:49 +02:00
Lasse Collin 426bdc709c CMake: Update the main comment and document CMAKE_BUILD_TYPE=Release. 2024-02-19 16:28:49 +02:00
Lasse Collin 4430e075f7 CMake: Use -O2 instead of -O3 in CMAKE_BUILD_TYPE=Release.
-O3 doesn't seem useful for speed but it makes the code bigger.
CMake makes is difficult for users to simply override the
optimization level: CFLAGS / CMAKE_C_FLAGS aren't helpful because
they go before CMAKE_C_FLAGS_RELEASE. Of course, users can override
CMAKE_C_FLAGS_RELEASE directly but then they have to remember to
add also -DNDEBUG to disable assertions.

This commit changes -O3 to -O2 in CMAKE_C_FLAGS_RELEASE if and only if
CMAKE_C_FLAGS_RELEASE cache variable doesn't already exist. So if
a custom value is passed on the command line (or reconfiguring an
already-configured build), the cache variable won't be modified.
2024-02-19 16:28:49 +02:00
Lasse Collin 025eb6d787 CMake: Handle symbol versioning on MicroBlaze specially.
This is to match configure.ac.
2024-02-19 16:28:49 +02:00
Lasse Collin 2edd1a35b2 CMake: Keep build working even if lib/*.[ch] are removed. 2024-02-19 12:21:37 +02:00
Lasse Collin d753e2ce47 CMake: Install documentation. 2024-02-19 12:21:37 +02:00
Lasse Collin 7a0405bea9 CMake: Bump maximum policy version to 3.28.
CMP0154 doesn't affect us since we don't use FILE_SET.
2024-02-19 12:21:37 +02:00
Lasse Collin c2264ffbe3 CMake: Build lzmainfo. 2024-02-19 12:21:37 +02:00
Lasse Collin 998d0b2953 CMake: Build lzmadec. 2024-02-19 12:21:37 +02:00
Lasse Collin 74e8bc7417 CMake: Add test_scripts.sh to the tests.
In contrast to Automake, skipping of this test when decoders
are disabled is handled at CMake side instead of test_scripts.sh
because CMake-build doesn't create config.h.
2024-02-19 12:21:37 +02:00
Lasse Collin 4808f238a7 CMake: Install scripts.
Compared to the Autotools-based build, this has simpler handling
for the shell (@POSIX_SHELL@) and extra PATH entry for the scripts
(configure has --enable-path-for-scripts=PREFIX). The simpler
metho should be enough for non-ancient systems and Solaris.
2024-02-19 12:21:37 +02:00
Lasse Collin 3462362ebd Scripts: Use @PACKAGE_VERSION@ instead of @VERSION@.
PACKAGE_VERSION was already used in liblzma.pc.in.
This way only one version @foo@ is used.
2024-02-19 12:21:37 +02:00
Lasse Collin 67610c245b CMake: Simplify symlink creation and install translated man pages.
It helps that cmake_install.cmake doesn't parallelize installation
so symlinks can be created so that the target is always known to
exist (a requirement on Windows in some cases).

This bumps the minimum CMake version from 3.13 to 3.14 to use
file(CREATE_LINK ...). It could be made to work on 3.13 by
calling "cmake -E create_symlink" but it's uglier code and
slower in "make install". 3.14 should be a reasonable version
to require nowadays, especially since the Autotools build
is still the primary build system for most OSes.
2024-02-19 12:21:37 +02:00
Lasse Collin 50cc1d8a5a CMake: Add support for building and installing xz with translations.
If gettext tools are available, the .po files listed in po/LINGUAS
are converted using msgfmt. This allows building with translations
directly from xz.git without Autotools.

If gettext tools aren't available, the Autotools-created .gmo files
in the "po" directory will be used. This allows CMake-based build
to use translations from Autotools-generated tarball.

If translation support is found (Intl_FOUND) but both the
gettext tools and the pre-generated .gmo files are missing,
then "make" will fail.
2024-02-19 12:21:37 +02:00
Lasse Collin 746c471643 liblzma: Remove commented-out code. 2024-02-19 11:58:33 +02:00
Lasse Collin 4ce300ce08 xz: Delete old commented-out code. 2024-02-17 23:07:35 +02:00
Lasse Collin cae9a5e0bf xz: Use stricter pledge(2) and Landlock sandbox.
This makes these sandboxing methods stricter when no files are
created or deleted. That is, it's a middle ground between the
initial sandbox and the strictest single-file-to-stdout sandbox:
this allows opening files for reading but output has to go to stdout.
2024-02-17 23:07:35 +02:00
Lasse Collin 02e3505991 xz: Support Landlock ABI version 4.
Linux 6.7 added support for ABI version 4 which restricts
TCP connections which xz won't need and thus those can be
forbidden now. Since the ABI version is handled at runtime,
supporting version 4 won't cause any compatibility issues.

Note that new enough kernel headers are required to get
version 4 support enabled at build time.
2024-02-17 23:07:35 +02:00
Lasse Collin 374868d81d xz: Move sandboxing code to sandbox.c and improve Landlock sandbox.
Landlock is now always used just like pledge(2) is: first in more
permissive mode and later (under certain common conditions) in
a strict mode that doesn't allow opening more files.

I put pledge(2) first in sandbox.c because it's the simplest API
to use and still somewhat fine-grained for basic applications.
So it's the simplest thing to understand for anyone reading sandbox.c.
2024-02-17 23:07:35 +02:00
Lasse Collin 7312dfbb02 xz: Tweak comments. 2024-02-17 23:07:35 +02:00
Lasse Collin c701a5909a xz: Fix message_init() description.
Also explicitly initialize progress_automatic to make it clear
that it can be read before message_init() sets it. Static variable
was initialized to false by default already so this is only for
clarity.
2024-02-17 23:07:35 +02:00
Lasse Collin 9466306719 Build: Makefile.am: Sort EXTRA_DIST.
Dirs first, then files in case-sensitive ASCII order.
2024-02-17 19:42:30 +02:00
Lasse Collin f3440e78c9 Build: Don't install TODO. 2024-02-17 19:42:30 +02:00
Jia Tan a7a3b62e2a Translations: Update the Korean man page translations. 2024-02-18 01:09:11 +08:00
Jia Tan 9b315db2d5 Translations: Update the Korean translation. 2024-02-18 01:08:32 +08:00
Lasse Collin 56246607df Build: Install translated lzmainfo man pages.
All other translated man pages were being installed but
lzmainfo had been forgotten.
2024-02-17 16:23:14 +02:00
Lasse Collin f1d6b88aef liblzma: Avoid implementation-defined behavior in the RISC-V filter.
GCC docs promise that it works and a few other compilers do
too. Clang/LLVM is documented source code only but unsurprisingly
it behaves the same as others on x86-64 at least. But the
certainly-portable way is good enough here so use that.
2024-02-17 16:01:32 +02:00
Lasse Collin 843ddc5f61 liblzma: Wrap a line exceeding 80 chars. 2024-02-17 15:50:21 +02:00
Sebastian Andrzej Siewior e9053c9072 liblzma/rangecoder: Exclude x32 from the x86-64 optimisation.
The x32 port has a x86-64 ABI in term of all registers but uses only
32bit pointer like x86-32. The assembly optimisation fails to compile on
x32. Given the state of x32 I suggest to exclude it from the
optimisation rather than trying to fix it.

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
2024-02-17 15:50:21 +02:00
Jia Tan 3d198fb13b Translations: Update the Spanish translation. 2024-02-17 21:05:07 +08:00
Jia Tan cf278bfe60 Translations: Update the Swedish translation. 2024-02-17 20:43:29 +08:00
Jia Tan b0f1a41be5 Translations: Update the Polish translation. 2024-02-17 20:41:38 +08:00
Jia Tan d74ed48b30 Translations: Update the Ukrainian translation. 2024-02-17 20:41:02 +08:00
Lasse Collin 711e22d5c5 Translations: Use the same sentence in xz.pot-header that the TP uses. 2024-02-16 17:53:34 +02:00
Jia Tan fb5f6aaf18 Fix typos discovered by codespell. 2024-02-16 22:54:59 +08:00
Jia Tan c64723bbb0 Translations: Update the Ukrainian man page translations. 2024-02-16 22:54:59 +08:00
Jia Tan 2895195ed0 Translations: Update the Ukrainian translation. 2024-02-16 22:54:59 +08:00
Lasse Collin 4c20781f4c Translations: Omit the generic copyright line from man page headers. 2024-02-15 22:33:49 +02:00
Jia Tan 4323bc3e0c Update m4/.gitignore. 2024-02-15 22:26:43 +08:00
Lasse Collin 5394a1665b Tests: tuktest.h: Treat Clang separately from GCC.
Don't assume that Clang defines __GNUC__ as the extensions
are available in clang-cl as well (and possibly in some other
Clang variants?).
2024-02-14 21:12:58 +02:00
Lasse Collin cce7330b9f Tests: tuktest.h: Add a missing word to a comment. 2024-02-14 21:11:03 +02:00
Lasse Collin 5dd8fc9452 Tests: tuktest.h: Fix the comment about STest. 2024-02-14 21:10:10 +02:00
Jia Tan 6f1790254a Bump version for 5.5.2beta. 2024-02-15 01:53:40 +08:00
Lasse Collin 924fdeedf4 liblzma: Fix validate_map.sh.
Adding the SPDX license identifier changed the line numbers.
2024-02-14 19:46:11 +02:00
Lasse Collin 22140a2df6 Build: Start the generated ChangeLog from around 5.4.0 instead of 5.2.0. 2024-02-14 19:38:34 +02:00
Lasse Collin 0b8cefa136 Fixed NEWS for 5.5.2beta. 2024-02-14 19:27:46 +02:00
Lasse Collin a4557bad96 liblzma: Silence warnings in --enable-small build. 2024-02-14 19:21:45 +02:00
Lasse Collin 38edf47323 Build: Install COPYING.0BSD as part of docs. 2024-02-14 19:15:58 +02:00
Lasse Collin b74e10bd83 Docs: List COPYING.0BSD in README. 2024-02-14 19:15:34 +02:00
Lasse Collin dfdb60ffe9 Docs: Include doc/examples/11_file_info.c in tarballs.
It was added in 2017 in c2e29f06a7
but it never got into any release tarballs because it was
forgotten to be added to Makefile.am.
2024-02-14 19:11:48 +02:00
Lasse Collin 160b686264 liblzma: Silence a warning. 2024-02-14 19:05:58 +02:00
Lasse Collin eeedd4d092 Add NEWS for 5.5.2beta. 2024-02-14 18:32:27 +02:00
Lasse Collin 8af7db854f xz: Mention lzmainfo if trying to use 'lzma --list'.
This kind of fixes the problem reported here:
https://bugs.launchpad.net/ubuntu/+source/xz-utils/+bug/1291020
2024-02-14 18:31:16 +02:00
Lasse Collin 0668907ff7 liblzma: Add comments. 2024-02-14 18:31:16 +02:00
Lasse Collin 109f1913d4 Scripts: Add lz4 support to xzgrep and xzdiff. 2024-02-14 18:31:16 +02:00
Lasse Collin de55485cb2 liblzma: Choose the range decoder variants using a bitmask macro. 2024-02-14 18:31:16 +02:00
Lasse Collin 0709c2b2d7 xz: Fix outdated threading related info on the man page. 2024-02-14 18:31:16 +02:00
Lasse Collin 3182a330c1 liblzma: Range decoder: Add x86-64 inline assembly.
It's compatible with GCC and Clang.
2024-02-14 18:31:16 +02:00
Lasse Collin cba2edc991 liblzma: Range decoder: Add branchless C code.
It's used only for basic bittrees and fixed-size reverse bittree
because those showed a clear benefit on x86-64 with GCC and Clang.
The other methods were more mixed and thus are commented out but
they should be tested on other archs.
2024-02-14 18:31:16 +02:00
Lasse Collin e290a72d6d liblzma: Clarify a comment. 2024-02-14 18:31:16 +02:00
Lasse Collin 5e04706b91 liblzma: LZMA decoder: Optimize loop comparison.
But now it needs one more local variable.
2024-02-14 18:31:16 +02:00
Lasse Collin 88276f9f2c liblzma: Optimize literal_subcoder() macro slightly. 2024-02-14 18:31:16 +02:00
Lasse Collin 5938f6de4d liblzma: LZ decoder: Add unlikely(). 2024-02-14 18:31:16 +02:00
Lasse Collin 9c252e3ed0 liblzma: LZ decoder: Remove a useless unlikely(). 2024-02-14 18:31:16 +02:00
Lasse Collin f3872a5947 liblzma: Optimize LZ decoder slightly.
Now extra buffer space is reserved so that repeating bytes for
any single match will never need to copy from two places (both
the beginning and the end of the buffer). This simplifies
dict_repeat() and helps a little with speed.

This seems to reduce .lzma decompression time about 2 %, so
with .xz and CRC it could be slightly less. The small things
add up still.
2024-02-14 18:31:16 +02:00
Lasse Collin eb518446e5 liblzma: LZMA decoder: Get rid of next_state[].
It's not completely obvious if this is better in the decoder.
It should be good if compiler can avoid creating a branch
(like using CMOV on x86).

This also makes lzma_encoder.c use the new macros.
2024-02-14 18:31:16 +02:00
Lasse Collin e0c0ee475c liblzma: LZMA decoder improvements.
This adds macros for bittree decoding which prepares the code
for alternative C versions and inline assembly.
2024-02-14 18:31:16 +02:00
Jia Tan de5c5e4176 liblzma: Creates Non-resumable and Resumable modes for lzma_decoder.
The new decoder resumes the first decoder loop in the Resumable mode.
Then, the code executes in Non-resumable mode until it detects that it
cannot guarantee to have enough input/output to decode another symbol.

The Resumable mode is how the decoder has always worked. Before decoding
every input bit, it checks if there is enough space and will save its
location to be resumed later. When the decoder has more input/output,
it jumps back to the correct sequence in the Resumable mode code.

When the input/output buffers are large, the Resumable mode is much
slower than the Non-resumable because it has more branches and is harder
for the compiler to optimize since it is in a large switch block.

Early benchmarking shows significant time improvement (8-10% on gcc and
clang x86) by using the Non-resumable code as much as possible.
2024-02-14 18:31:16 +02:00
Jia Tan e446ab7a18 liblzma: Creates separate "safe" range decoder mode.
The new "safe" range decoder mode is the same as old range decoder, but
now the default behavior of the range decoder will not check if there is
enough input or output to complete the operation. When the buffers are
close to fully consumed, the "safe" operations must be used instead. This
will improve speed because it will reduce the number of branches needed
for most of the range decoder operations.
2024-02-14 18:31:16 +02:00
Lasse Collin 7f6d9ca329 doxygen/footer.html: Add missing closing tags and don't open a new tab.
The footer template from Doxygen has the closing </body> </html>
as Doxygen doesn't add them otherwise.

target="_blank" was omitted as it's not useful here but
it can be slightly annoying as one cannot just go back
in the browser history.

Since the footer links to the license file in the same
directory and not to CC website, the rel attributes
can be omitted.
2024-02-14 18:31:16 +02:00
Lasse Collin 26d1527d34 Tweak the expressions in AUTHORS. 2024-02-14 18:31:16 +02:00
Lasse Collin d231d56580 Translations: Add the man page translators into man page header comment.
It looked odd to only have the original English authors listed
in the header comments of the translated files.
2024-02-14 18:31:16 +02:00
Lasse Collin 6d35fcb936 Translations: Translate also messages of lzmainfo.
lzmainfo has had translation support since 2009 at least but
it was never added to po/POTFILES.in so the messages weren't
translated. It's a very rarely needed tool so it's not too bad.

This also adds src/xz/mytime.c to po/POTFILES.in although there
are no translatable strings. It's simpler this way so that it
won't be forgotten if strings were ever added to that file.
2024-02-14 18:31:16 +02:00
Lasse Collin a9f369dd54 Translations: Add custom .pot header with SPDX license identifier.
The same is used for both po/xz.pot and po4a/xz-man.pot.
2024-02-14 18:31:16 +02:00
Lasse Collin 469cd6653b Translations: po4a/update-po: Add copyright notice to xz-man.pot.
All man pages are under 0BSD now so this is simple now.
2024-02-14 18:31:16 +02:00
Lasse Collin 28ce45e38f Update COPYING about the man pages of the scripts. 2024-02-14 18:31:16 +02:00
Lasse Collin e48287bf51 xzdiff, xzgrep, and xzmore: Rewrite the man pages.
The main reason is a kind of silly one:

xz-man.pot contains strings from all man pages in XZ Utils.
The man pages of xzdiff, xzgrep, and xzmore were under GPLv2
and the rest under 0BSD. Thus xz-man.pot contained strings
under two licences. po4a creates the translated man pages
from the combined 0BSD+GPLv2 xz-man.pot.

I haven't liked this mixing in xz-man.pot but the
Translation Project requires that all man pages must be
in the same .pot file. So a separate xz-man-gpl.pot
wasn't an option.

Since these man pages are short, rewriting them was quick enough.
Now xz-man.pot is entirely under 0BSD and marking the per-file
licenses is simpler.

As a bonus, some wording hopefully is now slightly better
although it's perhaps a matter of taste.

NOTE: In xzgrep.1, the EXIT STATUS section was written by me
in the commit d796b6d7fd so that's
why that section could be taken as is from the old xzgrep.1.
2024-02-14 18:31:16 +02:00
Lasse Collin 3e551b111b xzless: Update man page slightly.
The xz tool can decompress three file formats and xzless
has always supported uncompressed files too.
2024-02-14 18:31:16 +02:00
Lasse Collin 40f36da226 Translations: Change po/Makevars to add a copyright notice to po/xz.pot. 2024-02-14 18:31:16 +02:00
Lasse Collin 24192854e2 Translations: Update po/Makevars to use the template from gettext 0.22.4.
Also add SPDX license identifier now that there is a known license.
2024-02-14 18:31:16 +02:00
Lasse Collin b941549573 liblzma: Include the SPDX license identifier 0BSD to generated files.
Perhaps the generated files aren't even copyrightable but
using the same license for them as for the rest of the liblzma
keeps things more consistent for tools that look for license info.
2024-02-14 18:31:16 +02:00
Lasse Collin 8e4ec79483 liblzma: Fix compilation of price_tablegen.c.
It is built and run only manually so this didn't matter
unless one wanted to regenerate the price_table.c.
2024-02-14 18:31:16 +02:00
Lasse Collin e99bff3ffb Add SPDX license identifiers to GPL, LGPL, and FSFULLR files. 2024-02-14 18:31:16 +02:00
Lasse Collin 22af94128b Add SPDX license identifier into 0BSD source code files. 2024-02-14 18:31:16 +02:00
Lasse Collin 23de53421e liblzma: Sync the AUTHORS fix about SHA-256 to lzma.h. 2024-02-14 18:31:16 +02:00
Lasse Collin 689e0228ba Change most public domain parts to 0BSD.
Translations and doc/xz-file-format.txt and doc/lzma-file-format.txt
were not touched.

COPYING.0BSD was added.
2024-02-14 18:31:12 +02:00
Lasse Collin 76946dc433 Fix SHA-256 authors.
The initial commit 5d018dc035
in 2007 had a comment in sha256.c that the code is based on
Crypto++ Library 5.5.1. In 2009 the Authors list in sha256.c
and the AUTHORS file was updated with information that the
code had come from Crypto++ but via 7-Zip. I know I had viewed
7-Zip's SHA-256 code but back then the C code has been identical
enough with Crypto++, so I don't why I thought the author info
would need that extra step via 7-Zip for this single file.

Another error is that I had mixed sha.* and shacal2.* files
when checking for author info in Crypto++. The shacal2.* files
aren't related to liblzma's sha256.c and thus Kevin Springle's
code in Crypto++ isn't either.
2024-02-14 15:23:00 +02:00
Lasse Collin 21d9cbae9e Remove macosx/build.sh.
It was last updated in 2013.
2024-02-14 15:23:00 +02:00
Lasse Collin eac2c3c67f Doc: Remove doc/examples_old.
It was good to keep these around in parallel with the newer examples
but I think it's OK to remove the old ones at this point.
2024-02-14 15:23:00 +02:00
Jia Tan 89ea1a22f4 Tests: Add RISC-V filter support in a few places. 2024-02-13 23:33:27 +08:00
Jia Tan 45663443eb liblzma: Fix build error if only RISC-V BCJ filter is enabled.
If any other BCJ filter was enabled for encoding or decoding, then this
was not a problem.
2024-02-13 23:33:21 +08:00
Jia Tan 2f15597d67 Translations: Update the Korean translation. 2024-02-13 23:26:55 +08:00
Jia Tan df873143ad Translations: Update the Korean man page translations. 2024-02-13 01:55:53 +08:00
Jia Tan b3f415eddb Translations: Update the Chinese (simplified) translation. 2024-02-13 01:53:33 +08:00
Lasse Collin 9860d418d2 xzless: Use ||- in LESSOPEN with with "less" 451 and newer. 2024-02-09 23:21:01 +02:00
Lasse Collin fd0692b052 xzless: Use --show-preproc-errors with "less" 632 and newer.
This makes "less" show a warning if a decompression error occurred.
2024-02-09 23:00:05 +02:00
Jia Tan adb073da76 liblzma: Fix typo discovered by codespell. 2024-02-09 23:59:54 +08:00
Jia Tan 55d9fc883d Translations: Update the Swedish translation. 2024-02-09 20:01:06 +08:00
Jia Tan 55ba4a1ea3 Translations: Update the Spanish translation. 2024-02-08 20:09:04 +08:00
Jia Tan 7f2293cd80 Translations: Update the Spanish translation. 2024-02-07 21:34:35 +08:00
Jia Tan f4af2036bc Translations: Update the Polish translation. 2024-02-07 21:28:32 +08:00
Jia Tan e5e93bb816 Translations: Update the German translation. 2024-02-07 19:40:12 +08:00
Jia Tan 28f18ff8e2 Translations: Update the German man page translations. 2024-02-07 19:27:25 +08:00
Jia Tan cabfbc7947 Translations: Update the Romanian translation. 2024-02-06 23:44:06 +08:00
Jia Tan bf20c94f5d Translations: Update the Romanian man page translations. 2024-02-06 23:45:02 +08:00
Jia Tan 7c25ec9feb Translations: Update the Ukrainian translation. 2024-02-07 20:56:57 +08:00
Jia Tan b3523250e9 Translations: Update the Ukrainian man page translations. 2024-02-06 23:30:03 +08:00
Jia Tan a5c177f514 Update AUTHORS. 2024-02-02 01:39:28 +08:00
Jia Tan 7f68a68c19 liblzma: Update Authors list in crc32_arm64.h. 2024-02-02 01:38:51 +08:00
Jia Tan 97f9ba50b8 liblzma: Check HAVE_USABLE_CLMUL before omitting CRC32 table.
This was split from the prior commit so it could be easily applied to
the 5.4 branch.

Closes: https://github.com/tukaani-project/xz/pull/77
2024-02-01 20:09:11 +08:00
Jia Tan ca9015f4de liblzma: Check HAVE_USABLE_CLMUL before omitting CRC64 table.
If liblzma is configured with --disable-clmul-crc
CFLAGS="-msse4.1 -mpclmul", then it will fail to compile because the
generic version must be used but the CRC tables were not included.
2024-02-01 20:09:11 +08:00
Jia Tan 2f1552a91c liblzma: Only use ifunc in crcXX_fast.c if its needed.
The code was using HAVE_FUNC_ATTRIBUTE_IFUNC instead of CRC_USE_IFUNC.
With ARM64, ifunc is incompatible because it requires non-inline
function calls for runtime detection.
2024-02-01 20:09:11 +08:00
Jia Tan 30a25f3742 Docs: Add --disable-arm64-crc32 description to INSTALL. 2024-02-01 20:09:11 +08:00
Jia Tan 1940f0ec28 liblzma: Omit CRC tables when not needed with ARM64 optimizations.
This is similar to the existing x86-64 CLMUL conditions to omit the
tables. They were slightly refactored to improve readability.
2024-02-01 20:09:11 +08:00
Jia Tan 761f5b69a4 liblzma: Rename crc32_aarch64.h to crc32_arm64.h.
Even though the proper name for the architecture is aarch64, this
project uses ARM64 throughout. So the rename is for consistency.

Additionally, crc32_arm64.h was slightly refactored for the following
changes:

   * Added MSVC, FreeBSD, and macOS support in
     is_arch_extension_supported().

   * crc32_arch_optimized() now checks the size when aligning the
     buffer.

   * crc32_arch_optimized() loop conditions were slightly modified to
     avoid both decrementing the size and incrementing the buffer
     pointer.

   * Use the intrinsic wrappers defined in <arm_acle.h> because GCC and
     Clang name them differently.

   * Minor spacing and comment changes.
2024-02-01 20:09:11 +08:00
Jia Tan 455a08609c liblzma: Refactor crc_common.h.
The CRC_GENERIC is now split into CRC32_GENERIC and CRC64_GENERIC, since
the ARM64 optimizations will be different between CRC32 and CRC64.

For the same reason, CRC_ARCH_OPTIMIZED is split into
CRC32_ARCH_OPTIMIZED and CRC64_ARCH_OPTIMIZED.

ifunc will only be used with x86-64 CLMUL because the runtime detection
methods needed with ARM64 are not compatible with ifunc.
2024-02-01 20:09:11 +08:00
Jia Tan 61908e8160 CMake: Add support for ARM64 CRC32 instruction detection. 2024-02-01 20:09:11 +08:00
Jia Tan c5f6d79cc9 Build: Add support for ARM64 CRC32 instruction detection.
This adds --enable-arm64-crc32/--disable-arm64-crc32 (enabled by
default) for using the ARM64 CRC32 instruction. This can be disabled if
one knows the binary will never need to run on an ARM64 machine
with this instruction extension.
2024-02-01 20:09:09 +08:00
Chenxi Mao 849d0f282a Speed up CRC32 calculation on ARM64
The CRC32 instructions in ARM64 can calculate the CRC32 result
for 8 bytes in a single operation, making the use of ARM64
instructions much faster compared to the general CRC32 algorithm.

Optimized CRC32 will be enabled if ARM64 has CRC extension
running on Linux.

Signed-off-by: Chenxi Mao <chenxi.mao2013@gmail.com>
2024-01-27 21:49:26 +08:00
Jia Tan b43c3e48bf Bump version number for 5.5.1alpha. 2024-01-26 19:05:51 +08:00
Jia Tan c7a7ae1500 Add NEWS for 5.5.1alpha 2024-01-26 19:00:52 +08:00
Jia Tan 0ef8192e8d Add NEWS for 5.4.6. 2024-01-26 18:54:24 +08:00
Lasse Collin 93de7e751d Move doc/logo/xz-logo.png to "doc" and Doxygen footer to "doxygen".
The footer isn't a complete HTML file so having it in the doxygen
directory is a tiny bit clearer.
2024-01-24 20:00:57 +02:00
Jia Tan 00fa01698d README: Add COPYING.CC-BY-SA-4.0 entry to section 1.1.
The Overall documentation section (1.1) table spacing had to be adjusted
since the filename was very long.
2024-01-25 01:39:35 +08:00
Jia Tan e280470040 Build: Add the logo and license to the release. 2024-01-25 01:39:35 +08:00
Jia Tan b1ee6cf259 COPYING: Add the license for the XZ logo. 2024-01-25 01:39:29 +08:00
Jia Tan 31293ae707 Doxygen: Added the XZ logo and copyright information.
The PROJECT_LOGO field is now used to include the XZ logo. The footer
of each page now lists the copyright information instead of the default
footer. The license is also copied to statisfy the copyright and so the
link in the documentation can be local.
2024-01-25 01:06:01 +08:00
Lasse Collin 6daa4d0ea4 xz: Use threaded mode by defaut (as if --threads=0 was used).
This hopefully does more good than bad:

  + It's faster by default.

  + Only the threaded compressor creates files that
    can be decompressed in threaded mode.

  - Compression ratio is worse, usually not too much though.
    When it matters, -T1 must be used.

  - Memory usage increases.

  - Scripts that assume single-threaded mode but don't use -T1 will
    possibly use too much resources, for example, if they run
    multiple xz processes in parallel to compress multiple files.

  - Output from single-threaded and multi-threaded compressors
    differ but such changes could happen for other reasons too
    (they just haven't happened since 5.0.0).
2024-01-23 18:29:28 +02:00
Jia Tan a2dd2dc8e5 CI: Use RISC-V filter when building with BCJ support. 2024-01-23 23:55:44 +08:00
Jia Tan 3060e1070b Tests: Use smaller dictionary size in RISC-V test files. 2024-01-23 23:55:44 +08:00
Jia Tan 44ff2fa5c9 Tests: Skip RISC-V test files if decoder was not built. 2024-01-23 23:55:39 +08:00
Lasse Collin 6133a3f300 xz: Man page: Add more examples of LZMA2 options with BCJ filters. 2024-01-23 23:05:47 +08:00
Lasse Collin 50255feeaa liblzma: RISC-V filter: Use byte-by-byte access.
Not all RISC-V processors support fast unaligned access so
it's better to read only one byte in the main loop. This can
be faster even on x86-64 when compared to reading 32 bits at
a time as half the time the address is only 16-bit aligned.

The downside is larger code size on archs that do support
fast unaligned access.
2024-01-23 23:05:47 +08:00
Jia Tan db5eb5f563 xz: Update xz -lvv for RISC-V filter.
Version 5.6.0 will be shown, even though upcoming alphas and betas
will be able to support this filter. 5.6.0 looks nicer in the output and
people shouldn't be encouraged to use an unstable version in production
in any way.
2024-01-23 23:05:47 +08:00
Jia Tan e2870db5be Tests: Add two RISC-V Filter test files.
These test files achieve 100% code coverage in
src/liblzma/simple/riscv.c. They contain all of the instructions that
should be filtered and a few cases that should not.
2024-01-23 23:05:47 +08:00
Jia Tan b26a898693 xz: Update message in --long-help for RISC-V Filter. 2024-01-23 23:05:47 +08:00
Jia Tan 283f778908 xz: Update the man page for the RISC-V Filter.
A special note was added to suggest using four-byte alignment when the
compressed instruction extension is not present in a RISC-V binary.
2024-01-23 23:05:47 +08:00
Jia Tan ac3691ccca Tests: Add RISC-V Filter test in test_compress.sh. 2024-01-23 23:05:47 +08:00
Jia Tan 2959dbc735 liblzma: Update string_conversion.c to support RISC-V Filter. 2024-01-23 23:05:47 +08:00
Jia Tan 34372a5adb CMake: Support RISC-V BCJ Filter for encoding and decoding. 2024-01-23 23:05:47 +08:00
Jia Tan 440a2eccb0 liblzma: Add RISC-V BCJ filter.
The new Filter ID is 0x0B.

Thanks to Chien Wong <m@xv97.com> for the initial version of the Filter,
the xz CLI updates, and the Autotools build system modifications.

Thanks to Igor Pavlov for his many contributions to the design of
the filter.
2024-01-23 23:05:41 +08:00
Jia Tan 5540f4329b 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-19 23:08:14 +08:00
Jia Tan 22d86192f8 xz: Update website URLs in the man pages. 2024-01-19 23:08:14 +08:00
Jia Tan 6b63c4c613 liblzma: Update website URL. 2024-01-19 23:08:14 +08:00
Jia Tan fce4758018 Docs: Update website URLs. 2024-01-19 23:08:14 +08:00
Jia Tan c26812c5b2 Build: Update website URL. 2024-01-19 23:08:14 +08:00
Lasse Collin fbb3ce541e liblzma: CRC: Add a comment to crc_x86_clmul.h about BUILDING_ macros. 2024-01-11 15:25:00 +02:00
Lasse Collin 4f518c1b6b liblzma: CRC: Remove crc_always_inline, use lzma_always_inline instead.
Now crc_simd_body() in crc_x86_clmul.h is only called once
in a translation unit, we no longer need to be so cautious
about ensuring the always-inline behavior.
2024-01-11 15:24:35 +02:00
Lasse Collin 35c03ec6bf liblzma: CRC: Update CLMUL comments to more generic wording. 2024-01-11 14:39:46 +02:00
Lasse Collin 66f080e801 liblzma: Rename arch-specific CRC functions and macros.
CRC_CLMUL was split to CRC_ARCH_OPTIMIZED and CRC_X86_CLMUL.
CRC_ARCH_OPTIMIZED is defined when an arch-optimized version is used.
Currently the x86 CLMUL implementations are the only arch-optimized
versions, and these also use the CRC_x86_CLMUL macro to tell when
crc_x86_clmul.h needs to be included.

is_clmul_supported() was renamed to is_arch_extension_supported().
crc32_clmul() and crc64_clmul() were renamed to
crc32_arch_optimized() and crc64_arch_optimized().
This way the names make sense with arch-specific non-CLMUL
implementations as well.
2024-01-11 14:29:42 +02:00
Lasse Collin 3dbed75b0b liblzma: Fix a comment in crc_common.h. 2024-01-11 14:29:42 +02:00
Lasse Collin 419f55f9df liblzma: Avoid extern lzma_crc32_clmul() and lzma_crc64_clmul().
A CLMUL-only build will have the crcxx_clmul() inlined into
lzma_crcxx(). Previously a jump to the extern lzma_crcxx_clmul()
was needed. Notes about shared liblzma on ELF platforms:

  - On platforms that support ifunc and -fvisibility=hidden, this
    was silly because CLMUL-only build would have that single extra
    jump instruction of extra overhead.

  - On platforms that support neither -fvisibility=hidden nor linker
    version script (liblzma*.map), jumping to lzma_crcxx_clmul()
    would go via PLT so a few more instructions of overhead (still
    not a big issue but silly nevertheless).

There was a downside with static liblzma too: if an application only
needs lzma_crc64(), static linking would make the linker include the
CLMUL code for both CRC32 and CRC64 from crc_x86_clmul.o even though
the CRC32 code wouldn't be needed, thus increasing code size of the
executable (assuming that -ffunction-sections isn't used).

Also, now compilers are likely to inline crc_simd_body()
even if they don't support the always_inline attribute
(or MSVC's __forceinline). Quite possibly all compilers
that build the code do support such an attribute. But now
it likely isn't a problem even if the attribute wasn't supported.

Now all x86-specific stuff is in crc_x86_clmul.h. If other archs
The other archs can then have their own headers with their own
is_clmul_supported() and crcxx_clmul().

Another bonus is that the build system doesn't need to care if
crc_clmul.c is needed.

is_clmul_supported() stays as inline function as it's not needed
when doing a CLMUL-only build (avoids a warning about unused function).
2024-01-11 14:29:42 +02:00
Lasse Collin e3833e297d liblzma: crc_clmul.c: Add crc_attr_target macro.
This reduces the number of the complex #if directives.
2024-01-11 14:29:42 +02:00
Lasse Collin d164ac0e62 liblzma: Simplify existing cases with lzma_attr_no_sanitize_address. 2024-01-11 14:29:42 +02:00
Lasse Collin 9523c1300d liblzma: #define crc_attr_no_sanitize_address in crc_common.h. 2024-01-11 14:29:38 +02:00
Lasse Collin 93d144f093 liblzma: CRC: Add empty lines.
And remove one too.
2024-01-10 17:19:03 +02:00
Lasse Collin 0c7e854ffd liblzma: crc_clmul.c: Tidy up the location of MSVC pragma.
It makes no difference in practice.
2024-01-10 17:19:03 +02:00
Lasse Collin 15cf3f04f2 Update THANKS. 2023-12-28 17:17:39 +02:00
Lasse Collin cd64dd70d5 liblzma: Use 8-byte method in memcmplen.h on ARM64.
It requires fast unaligned access to 64-bit integers
and a fast instruction to count leading zeros in
a 64-bit integer (__builtin_ctzll()). This perhaps
should be enabled on some other archs too.

Thanks to Chenxi Mao for the original patch:
https://github.com/tukaani-project/xz/pull/75 (the first commit)
According to the numbers there, this may improve encoding
speed by about 3-5 %.

This enables the 8-byte method on MSVC ARM64 too which
should work but wasn't tested.
2023-12-28 17:17:39 +02:00
Lasse Collin 12c90c00f0 liblzma: Check also for __clang__ in memcmplen.h.
This change hopefully makes no practical difference as Clang
likely was detected via __GNUC__ or _MSC_VER already.
2023-12-28 17:17:39 +02:00
Jia Tan 133c5851eb Translations: Update the French translation. 2023-12-21 21:39:08 +08:00
Jia Tan 710cbc186c 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-21 20:53:27 +08:00
Jia Tan 4e1c695676 Docs: Update --enable-sandbox option in INSTALL.
xzdec now also uses the sandbox when its configured.
2023-12-21 20:53:27 +08:00
Jia Tan ebddf20214 CMake: Move sandbox detection outside of xz section.
The sandbox is now enabled for xzdec as well, so it no longer belongs
in just the xz section. xz and xzdec are always built, except for older
MSVC versions, so there isn't a need to conditionally show the sandbox
configuration. CMake will do a little unecessary work on older MSVC
versions that can't build xz or xzdec, but this is a very small
downside.
2023-12-21 20:53:23 +08:00
Jia Tan 5feb09266f Build: Allow sandbox to be configured for just xzdec.
If xz is disabled, then xzdec can still use the sandbox.
2023-12-20 22:43:44 +08:00
Jia Tan d74fb5f060 xzdec: Add sandbox support for Pledge, Capsicum, and Landlock.
A very strict sandbox is used when the last file is decompressed. The
likely most common use case of xzdec is to decompress a single file.
The Pledge sandbox is applied to the entire process with slightly more
relaxed promises, until the last file is processed.

Thanks to Christian Weisgerber for the initial patch adding Pledge
sandboxing.
2023-12-19 21:18:28 +08:00
Jia Tan b34b6a9912 liblzma: Initialize lzma_lz_encoder pointers with NULL.
This fixes the recent change to lzma_lz_encoder that used memzero
instead of the NULL constant. On some compilers the NULL constant
(always 0) may not equal the NULL pointer (this only needs to guarentee
to not point to valid memory address).

Later code compares the pointers to the NULL pointer so we must
initialize them with the NULL pointer instead of 0 to guarentee
code correctness.
2023-12-20 21:38:39 +08:00
Jia Tan 183a62f0b5 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.

This is fixed by using memzero() to set all members of lzma_lz_encoder
to NULL after it is allocated. This ensures this mistake will not occur
here in the future if any additional function pointers are added.
2023-12-16 20:51:38 +08:00
Jia Tan 1a1bb381db liblzma: Tweak a comment. 2023-12-16 20:30:55 +08:00
Jia Tan 55810780e0 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-16 20:28:21 +08:00
Jia Tan 5dad6f628a 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-16 20:18:47 +08:00
Jia Tan e1b1a9d637 Docs: Update repository URL in Changelog. 2023-12-16 11:20:20 +08:00
Jia Tan f9b82bc64a CI: Update Upload Artifact Action. 2023-12-15 16:56:31 +08:00
Jia Tan d0b24efe6c 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-07 21:48:07 +08:00
Jia Tan 4a972a8ee3 Update THANKS. 2023-12-07 20:06:57 +08:00
Jia Tan ee2f483500 Tests: Minor cleanups to OSS-Fuzz files.
Most of these fixes are small typos and tweaks. A few were caused by bad
advice from me. Here is the summary of what is changed:

- Author line edits

- Small comment changes/additions

- Using the return value in the error messages in the fuzz targets'
  coder initialization code

- Removed fuzz_encode_stream.options. This set a max length, which may
  prevent some worthwhile code paths from being properly exercised.

- Removed the max_len option from fuzz_decode_stream.options for the
  same reason as fuzz_encode_stream. The alone decoder fuzz target still
  has this restriction.

- Altered the dictionary contents for fuzz_lzma.dict. Instead of keeping
  the properties static and varying the dictionary size, the properties
  are varied and the dictionary size is kept small. The dictionary size
  doesn't have much impact on the code paths but the properties do.

Closes: https://github.com/tukaani-project/xz/pull/73
2023-12-07 20:06:57 +08:00
Maksym Vatsyk 483bb90eec Tests: Add fuzz_encode_stream ossfuzz target.
This fuzz target handles .xz stream encoding. The first byte of input
is used to dynamically set the preset level in order to increase the
fuzz coverage of complex critical code paths.
2023-12-07 20:06:57 +08:00
Maksym Vatsyk 7ca8c9869d Tests: Add fuzz_decode_alone OSS-Fuzz target
This fuzz target that handles LZMA alone decoding. A new fuzz
dictionary .dict was also created with common LZMA header values to
help speed up the discovery of valid headers.
2023-12-07 20:06:57 +08:00
Maksym Vatsyk 37581a77ad Tests: Update OSS-Fuzz Makefile.
All .c files can be built as separate fuzz targets. This simplifies
the Makefile by allowing us to use wildcards instead of having a
Makefile target for each fuzz target.
2023-12-07 20:06:54 +08:00
Maksym Vatsyk 28ce6a1c2a Tests: Move common OSS-Fuzz target code to .h file. 2023-12-07 20:06:54 +08:00
Maksym Vatsyk bf0521ea15 Tests: Rename OSS-Fuzz files. 2023-12-07 20:06:51 +08:00
Jia Tan 685094b8e1 Update THANKS. 2023-11-30 23:10:43 +08:00
Kian-Meng Ang 3b3023e00b Tests: Fix typos 2023-11-30 23:08:05 +08:00
Kian-Meng Ang 424d46ead8 xz: Fix typo 2023-11-30 23:08:05 +08:00
Jia Tan 35558adf9c Update THANKS. 2023-11-30 20:41:00 +08:00
Jia Tan fd170e8557 CI: Test musl libc builds on Ubuntu runner. 2023-11-30 20:09:46 +08:00
Jia Tan db2b4aa068 CI: Allow ci_build.sh to set a different C compiler. 2023-11-30 20:09:46 +08:00
Jia Tan ff7badef53 CMake: Use consistent indentation with check_c_source_compiles(). 2023-11-30 20:09:46 +08:00
Jia Tan d4af167570 CMake: Change __attribute__((__ifunc__())) detection.
This renames ALLOW_ATTR_IFUNC to USE_ATTR_IFUNC and applies the ifunc
detection changes that were made to the Autotools build.

Fixes: https://github.com/tukaani-project/xz/issues/70
2023-11-30 20:07:34 +08:00
Jia Tan 20ecee40a0 Docs: Update INSTALL for --enable_ifunc change. 2023-11-30 20:05:09 +08:00
Jia Tan ffb456593d Build: Change --enable-ifunc handling.
Some compilers support __attribute__((__ifunc__())) even though the
dynamic linker does not. The compiler is able to create the binary
but it will fail on startup. So it is not enough to just test if
the attribute is supported.

The default value for enable_ifunc is now auto, which will attempt
to compile a program using __attribute__((__ifunc__())). There are
additional checks in this program if glibc is being used or if it
is running on FreeBSD.

Setting --enable-ifunc will skip this test and always enable
__attribute__((__ifunc__())), even if is not supported.
2023-11-30 20:04:42 +08:00
Lasse Collin 12b89bcc99 xz: Tweak a comment. 2023-11-23 17:39:10 +02:00
Jia Tan 2ab2e4b5a5 xz: Use is_tty() in message.c. 2023-11-23 22:40:27 +08:00
Jia Tan 584e3a258f 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-11-23 22:40:20 +08:00
Jia Tan 6b05f827f5 tuklib_integer: Fix typo discovered by codespell.
Based on internet dictionary searches, 'choise' is an outdated spelling
of 'choice'.
2023-11-22 20:39:41 +08:00
Lasse Collin 659aca0d69 xz: Move the check for --suffix with --format=raw a few lines earlier.
Now it reads from argv[] instead of args->arg_names.
2023-11-18 01:56:09 +08:00
Jia Tan ca278eb2b7 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-11-18 01:56:05 +08:00
Jia Tan 2a732aba22 xz: Fix a bug with --files and --files0 in raw mode without a suffix.
The following command caused a segmentation fault:

    xz -Fraw --lzma1 --files=foo

when foo was a valid file. The usage of --files or --files0 was not
being checked when compressing or decompressing in raw mode without a
suffix. The suffix checking code was meant to validate that all files
to be processed are "-" (if not writing to standard out), meaning the
data is only coming from standard in. In this case, there were no file
names to check since --files and --files0 store their file name in a
different place.

Later code assumed the suffix was set and caused a segmentation fault.
Now, the above command results in an error.
2023-11-17 23:16:55 +08:00
Jia Tan 299920bab9 Tests: Fix typo in a comment. 2023-11-17 20:04:58 +08:00
Jia Tan f481523baa xz: Refactor suffix test with raw format.
The previous version set opt_stdout, but this caused an issue with
copying an input file to standard out when decompressing an unknown file
type. The following needs to result in an error:

    echo foo | xz -df

since -c, --stdout is not used. This fixes the previous error by not
setting opt_stdout.
2023-11-15 23:40:13 +08:00
Jia Tan 837ea40b1c xz: Move suffix check after stdout mode is detected.
This fixes a bug introduced in cc5aa9ab13
when the suffix check was initially moved. This caused a situation that
previously worked:

    echo foo | xz -Fraw --lzma1 | wc -c

to fail because the old code knew that this would write to standard out
so a suffix was not needed.
2023-11-14 20:27:46 +08:00
Jia Tan d4f4a4d040 xz: Detect when all data will be written to standard out earlier.
If the -c, --stdout argument is not used, then we can still detect when
the data will be written to standard out if all of the provided
filenames are "-" (denoting standard in) or if no filenames are
provided.
2023-11-14 20:27:04 +08:00
Jia Tan 2ade7246e7 liblzma: Add missing comments to lz_encoder.h. 2023-11-09 01:21:53 +08:00
Jia Tan 5fe1450603 Add NEWS for 5.4.5. 2023-11-01 20:58:58 +08:00
Lasse Collin 46007049cd 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-10-31 21:41:09 +02:00
Jia Tan 148e20607e Build: Fix text wrapping in an output message. 2023-10-31 21:54:11 +08:00
Lasse Collin 8c36ab79cb liblzma: Add a note why crc_always_inline exists for now.
Solaris Studio is a possible example (not tested) which
supports the always_inline attribute but might not get
detected by the common.h #ifdefs.
2023-10-30 18:44:32 +02:00
Lasse Collin e7a86b94cd liblzma: Use lzma_always_inline in memcmplen.h. 2023-10-30 18:44:32 +02:00
Lasse Collin dcfe563299 liblzma: #define lzma_always_inline in common.h. 2023-10-30 18:44:32 +02:00
Lasse Collin 41113fe30a liblzma: Use lzma_attr_visibility_hidden on private extern declarations.
These variables are internal to liblzma and not exposed in the API.
2023-10-30 18:06:25 +02:00
Lasse Collin a2f5ca706a 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-30 18:03:39 +02:00
Lasse Collin 2c7ee92e44 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-26 21:46:06 +03:00
Lasse Collin 597f49b614 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-26 21:46:06 +03:00
Lasse Collin 1bc548b821 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-26 21:46:06 +03:00
Lasse Collin 2add71966f 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-26 21:46:06 +03:00
Lasse Collin a7d1b2825c 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-26 21:46:06 +03:00
Lasse Collin 80e0750e39 CMake: Create liblzma.def when building liblzma.dll with MinGW-w64. 2023-10-26 21:46:06 +03:00
Lasse Collin 08d12595f4 CMake: Change one CMAKE_CURRENT_SOURCE_DIR to CMAKE_CURRENT_LIST_DIR.
In this case they have identical values.
2023-10-26 21:46:06 +03:00
Lasse Collin e67aaf698d 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-26 18:58:21 +03:00
Lasse Collin 88588b1246 Build: Detect -fsanitize= in CFLAGS and incompatible build options.
Now configure will fail if -fsanitize= is found in CFLAGS
and sanitizer-incompatible ifunc or Landlock sandboxing
would be used. These are incompatible with one or more sanitizers.
It's simpler to reject all -fsanitize= uses instead of trying to
pass those that might not cause problems.

CMake-based build was updated similarly. It lets the configuration
finish (SEND_ERROR instead of FATAL_ERROR) so that both error
messages can be seen at once.
2023-10-25 20:18:04 +03:00
Jia Tan 5e3d890f88 CI: Disable sandboxing in fsanitize=address,undefined job.
The sandboxing on Linux now supports Landlock, which restricts all
supported filesystem actions after xz opens the files it needs. The
sandbox is only enabled when one file is input and we are writing to
standard out. With fsanitize=address,undefined, the instrumentation
needs to read additional files after the sandbox is in place. This
forces all xz based test to fail, so the sandbox must instead be
disabled.
2023-10-24 00:50:08 +08:00
Jia Tan b1408987ea CI: Allow disabling the sandbox in ci_build.sh. 2023-10-24 00:15:39 +08:00
Lasse Collin 91c435cf1c 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-22 19:03:52 +03:00
Lasse Collin fa1609eb93 Docs: Update INSTALL about sandboxing support. 2023-10-22 19:03:52 +03:00
Lasse Collin 8276c7f41c xz: Support basic sandboxing with Linux Landlock (ABI versions 1-3).
It is enabled only when decompressing one file to stdout,
similar to how Capsicum is used.

Landlock was added in Linux 5.13.
2023-10-22 19:03:52 +03:00
Lasse Collin 3a1e9fd031 CMake: Edit threading related messages.
It's mostly to change from "thread method" to "threading method".
2023-10-22 19:03:52 +03:00
Lasse Collin bf01135252 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-22 19:03:52 +03:00
Lasse Collin 3f53870c24 CMake: Add sandboxing support. 2023-10-22 19:03:52 +03:00
Lasse Collin 2e2cd11535 Simplify detection of Capsicum support.
This removes support for FreeBSD 10.0 and 10.1 which used
<sys/capability.h> instead of <sys/capsicum.h>. Support for
FreeBSD 10.1 ended on 2016-12-31. So now FreeBSD >= 10.2 is
required to enable Capsicum support.

This also removes support for Capsicum on Linux (libcaprights)
which seems to have been unmaintained since 2017 and Linux 4.11:
https://github.com/google/capsicum-linux
2023-10-22 19:03:52 +03:00
Lasse Collin c57858b60e xz/Windows: Allow clock_gettime with POSIX threads.
If winpthreads are used for threading, it's OK to use clock_gettime()
from winpthreads too.
2023-10-22 18:59:45 +03:00
Lasse Collin dd32f628bb mythread.h: Make MYTHREAD_POSIX compatible with MinGW-w64's winpthreads.
This might be almost useless but it doesn't need much extra code either.
2023-10-22 18:59:45 +03:00
Lasse Collin 680e52cdd0 CMake: Check for clock_gettime() even on Windows.
This mirrors configure.ac although currently MinGW-w64 builds
don't use clock_gettime() even if it is found.
2023-10-22 18:59:45 +03:00
Lasse Collin 1c1a8c3ee4 Build: Check for clock_gettime() even if not using POSIX threads.
See the new comment in the code.

This also makes the check for clock_gettime() run with MinGW-w64
with which we don't want to use clock_gettime(). The previous
commit already took care of this situation.
2023-10-22 18:59:45 +03:00
Lasse Collin 46fd991cd2 xz/Windows: Ensure that clock_gettime() isn't used with MinGW-w64.
This commit alone doesn't change anything in the real-world:

  - configure.ac currently checks for clock_gettime() only
    when using pthreads.

  - CMakeLists.txt doesn't check for clock_gettime() on Windows.

So clock_gettime() wasn't used with MinGW-w64 before either.

clock_gettime() provides monotonic time and it's better than
gettimeofday() in this sense. But clock_gettime() is defined
in winpthreads, and liblzma or xz needs nothing else from
winpthreads. By avoiding clock_gettime(), we avoid the dependency on
libwinpthread-1.dll or the need to link against the static version.

As a bonus, GetTickCount64() and MinGW-w64's gettimeofday() can be
faster than clock_gettime(CLOCK_MONOTONIC, &tv). The resolution
is more than good enough for the progress indicator in xz.
2023-10-22 18:59:45 +03:00
Lasse Collin cdb4d91f24 xz/Windows: Use GetTickCount64() with MinGW-w64 if using Vista threads. 2023-10-22 18:59:45 +03:00
Jia Tan 988e09f27b liblzma: Move is_clmul_supported() back to crc_common.h.
This partially reverts creating crc_clmul.c
(8c0f9376f5) where is_clmul_supported()
was moved, extern'ed, and renamed to lzma_is_clmul_supported(). This
caused a problem when the function call to lzma_is_clmul_supported()
results in a call through the PLT. ifunc resolvers run very early in
the dynamic loading sequence, so the PLT may not be setup properly at
this point. Whether the PLT is used or not for
lzma_is_clmul_supported() depened upon the compiler-toolchain used and
flags.

In liblzma compiled with GCC, for instance, GCC will go through the PLT
for function calls internal to liblzma if the version scripts and
symbol visibility hiding are not used. If lazy-binding is disabled,
then it would have made any program linked with liblzma fail during
dynamic loading in the ifunc resolver.
2023-10-21 00:01:29 +08:00
Jia Tan 105c7ca90d Build: Remove check for COND_CHECK_CRC32 in check/Makefile.inc.
Currently crc32 is always enabled, so COND_CHECK_CRC32 must always be
set. Because of this, it makes the recent change to conditionally
compile check/crc_clmul.c appear wrong since that file has CLMUL
implementations for both CRC32 and CRC64.
2023-10-19 16:23:32 +08:00
Jia Tan 1397571704 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-19 16:09:01 +08:00
Jia Tan c60b25569d liblzma: Fix -fsanitize=address failure with crc_clmul functions.
After forcing crc_simd_body() to always be inlined it caused
-fsanitize=address to fail for lzma_crc32_clmul() and
lzma_crc64_clmul(). The __no_sanitize_address__ attribute was added
to lzma_crc32_clmul() and lzma_crc64_clmul(), but not removed from
crc_simd_body(). ASAN and inline functions behavior has changed over
the years for GCC specifically, so while strictly required we will
keep __attribute__((__no_sanitize_address__)) on crc_simd_body() in
case this becomes a requirement in the future.

Older GCC versions refuse to inline a function with ASAN if the
caller and callee do not agree on sanitization flags
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89124#c3). If the
function was forced to be inlined, it will not compile if the callee
function has __no_sanitize_address__ but the caller doesn't.
2023-10-19 01:15:20 +08:00
Lasse Collin 9a78971261 tuklib_integer: Update the CMake test for fast unaligned access. 2023-10-18 19:02:45 +03:00
Lasse Collin 2f81ac852b Build: Enabled unaligned access by default on PowerPC64LE and some RISC-V.
PowerPC64LE wasn't tested but it seems like a safe change.
POWER8 supports unaligned access in little endian mode. Testing
on godbolt.org shows that GCC uses unaligned access by default.

The RISC-V macro __riscv_misaligned_fast is very new and not
in any stable compiler release yet.

Documentation in INSTALL was updated to match.

Documentation about an autodetection bug when using ARM64 GCC
with -mstrict-align was added to INSTALL.

CMake files weren't updated yet.
2023-10-18 19:02:45 +03:00
Lasse Collin c8f715f1bc 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-18 19:02:45 +03:00
Lasse Collin 6828242735 tuklib_integer: Add missing write64be and write64le fallback functions. 2023-10-18 19:02:45 +03:00
Jia Tan 1c8884f0af liblzma: Set the MSVC optimization fix to only cover lzma_crc64_clmul().
After testing a 32-bit Release build on MSVC, only lzma_crc64_clmul()
has the bug. crc_simd_body() and lzma_crc32_clmul() do not need the
optimizations disabled.
2023-10-18 23:54:41 +08:00
Lasse Collin 5ce0f7a48b liblzma: CRC_USE_GENERIC_FOR_SMALL_INPUTS cannot be used with ifunc. 2023-10-18 23:54:41 +08:00
Lasse Collin 2773538049 liblzma: Include common.h in crc_common.h.
crc_common.h depends on common.h. The headers include common.h except
when there is a reason to not do so.
2023-10-18 23:54:41 +08:00
Jia Tan e13b7947b9 liblzma: Add include guards to crc_common.h. 2023-10-18 23:54:41 +08:00
Jia Tan 40abd88afc liblzma: Add the crc_always_inline macro to crc_simd_body().
Forcing this to be inline has a significant speed improvement at the
cost of a few repeated instructions. The compilers tested on did not
inline this function since it is large and is used twice in the same
translation unit.
2023-10-18 23:54:41 +08:00
Jia Tan a5966c276b liblzma: Create crc_always_inline macro.
This macro must be used instead of the inline keyword. On MSVC, it is
a replacement for __forceinline which is an MSVC specific keyword that
should not be used with inline (it will issue a warning if it is).

It does not use a build system check to determine if
__attribute__((__always_inline__)) since all compilers that can use
CLMUL extensions (except the special case for MSVC) should support this
attribute. If this assumption is incorrect then it will result in a bug
report instead of silently producing slow code.
2023-10-18 23:54:41 +08:00
Jia Tan 96b663f67c liblzma: Refactor CRC comments.
A detailed description of the three dispatch methods was added. Also,
duplicated comments now only appear in crc32_fast.c or were removed from
both crc32_fast.c and crc64_fast.c if they appeared in crc_clmul.c.
2023-10-18 23:54:41 +08:00
Jia Tan 8c0f9376f5 liblzma: Create crc_clmul.c.
Both crc32_clmul() and crc64_clmul() are now exported from
crc32_clmul.c as lzma_crc32_clmul() and lzma_crc64_clmul(). This
ensures that is_clmul_supported() (now lzma_is_clmul_supported()) is
not duplicated between crc32_fast.c and crc64_fast.c.

Also, it encapsulates the complexity of the CLMUL implementations into a
single file and reduces the complexity of crc32_fast.c and crc64_fast.c.
Before, CLMUL code was present in crc32_fast.c, crc64_fast.c, and
crc_common.h.

During the conversion, various cleanups were applied to code (thanks to
Lasse Collin) including:

- Require using semicolons with MASK_/L/H/LH macros.
- Variable typing and const handling improvements.
- Improvements to comments.
- Fixes to the pragmas used.
- Removed unneeded variables.
- Whitespace improvements.
- Fixed CRC_USE_GENERIC_FOR_SMALL_INPUTS handling.
- Silenced warnings and removed the need for some #pragmas
2023-10-18 23:54:36 +08:00
Jia Tan a3ebc2c516 liblzma: Define CRC_USE_IFUNC in crc_common.h.
When ifunc is supported, we can define a simpler macro instead of
repeating the more complex check in both crc32_fast.c and crc64_fast.c.
2023-10-18 20:41:11 +08:00
Hans Jansen f1cd9d7194 liblzma: Added crc32_clmul to crc32_fast.c. 2023-10-13 20:54:05 +08:00
Hans Jansen 93e6fb08b2 liblzma: Moved CLMUL CRC logic to crc_common.h.
crc64_fast.c was updated to use the code from crc_common.h instead.
2023-10-13 20:54:05 +08:00
Hans Jansen 233885a437 liblzma: Rename crc_macros.h to crc_common.h. 2023-10-13 20:54:05 +08:00
Gabriela Gutierrez 37947d4a75 CI: Bump and ref actions by commit SHA in windows-ci.yml
Referencing actions by commit SHA in GitHub workflows guarantees you are using an immutable version. Actions referenced by tags and branches are more vulnerable to attacks, such as the tag being moved to a malicious commit or a malicious commit being pushed to the branch.

It's important to make sure the SHA's are from the original repositories and not forks.

For reference:

https://github.com/msys2/setup-msys2/releases/tag/v2.20.1
27b3aa77f6

https://github.com/actions/checkout/releases/tag/v4.1.0
8ade135a41

https://github.com/actions/upload-artifact/releases/tag/v3.1.3
a8a3f3ad30

Signed-off-by: Gabriela Gutierrez <gabigutierrez@google.com>
2023-10-13 20:03:13 +08:00
Gabriela Gutierrez f28cc9bd48 CI: Bump and ref actions by commit SHA in ci.yml
Referencing actions by commit SHA in GitHub workflows guarantees you are using an immutable version. Actions referenced by tags and branches are more vulnerable to attacks, such as the tag being moved to a malicious commit or a malicious commit being pushed to the branch.

It's important to make sure the SHA's are from the original repositories and not forks.

For reference:

https://github.com/actions/checkout/releases/tag/v4.1.0
8ade135a41

https://github.com/actions/upload-artifact/releases/tag/v3.1.3
a8a3f3ad30

Signed-off-by: Gabriela Gutierrez <gabigutierrez@google.com>
2023-10-13 20:03:13 +08:00
Jia Tan f74f174006 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-12 20:12:18 +08:00
Lasse Collin 5c4bca521e Update THANKS. 2023-10-06 19:36:35 +03:00
Lasse Collin d91cb6e884 CMake/Windows: Fix when the windres workaround is applied.
CMake doesn't set WIN32 on CYGWIN but the workaround is
probably needed on Cygwin too. Same for MSYS and MSYS2.

The workaround must not be used with Clang that is acting in
MSVC mode. This fixes it by checking for the known environments
that need the workaround instead of using "NOT MSVC".

Thanks to Martin Storsjö.
0570308ddd (commitcomment-129098431)
2023-10-06 19:32:06 +03:00
Jia Tan 01e34aa117 CI: Disable CLANG64 MSYS2 environment until bug is resolved.
lld 17.0.1 searches for libraries to link first in the toolchain
directories before the local directory when building. The is a problem
for us because liblzma.a is installed in MSYS2 CLANG64 by default and
xz.exe will thus use the installed library instead of the one being
built.

This causes tests to fail when they are expecting features to be
disabled. More importantly, it will compile xz.exe with an incorrect
liblzma and could cause unexpected behavior by being unable to update
liblzma code in static builds. The CLANG64 environment can be tested
again once this is fixed.

Link to bug: https://github.com/llvm/llvm-project/issues/67779.
2023-09-29 22:11:54 +08:00
Jia Tan 30d0c35327 CMake: Rename xz and man page symlink custom targets.
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
80a1a8bb83.
2023-09-29 20:14:39 +08:00
Jia Tan 506d03127a CMake: Specify LINKER_LANGUAGE for libgnu target to fix Ninja Generator.
CMake is unable to guess the linker language for just a header file so
it must be explicitly set.
2023-09-29 19:58:44 +08:00
Lasse Collin 0570308ddd CMake: Fix Windows build with Clang/LLVM 17.
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.

See also:
2bcc0fdc58
2023-09-27 20:49:46 +03:00
Lasse Collin 5a9af95f85 liblzma: Update a comment.
The C standards don't allow an empty translation unit which can be
avoided by declaring something, without exporting any symbols.

When I committed f644473a21 I had
a feeling that some specific toolchain somewhere didn't like
empty object files (assembler or maybe "ar" complained) but
I cannot find anything to confirm this now. Quite likely I
remembered nonsense. I leave this here as a note to my future self. :-)
2023-09-26 21:47:13 +03:00
Jia Tan 8ebaf3f665 liblzma: Avoid compiler warning without creating extra symbol.
When the generic fast crc64 method is used, then we omit
lzma_crc64_table[][]. Similar to
d9166b52cf, we can avoid compiler warnings
with -Wempty-translation-unit (Clang) or -pedantic (GCC) by creating a
never used typedef instead of an extra symbol.
2023-09-27 00:04:40 +08:00
Lasse Collin 092d21db2e Build: Update the comment about -Werror usage in checks. 2023-09-26 17:24:15 +03:00
Lasse Collin a37a276338 Build: Fix __attribute__((ifunc(...))) detection with clang -Wall.
Now if user-supplied CFLAGS contains -Wall -Wextra -Wpedantic
the two checks that need -Werror will still work.

At CMake side there is add_compile_options(-Wall -Wextra)
but it didn't affect the -Werror tests. So with both Autotools
and CMake only user-supplied CFLAGS could make the checks fail
when they shouldn't.

This is not a full fix as things like -Wunused-macros in
user-supplied CFLAGS will still cause problems with both
GCC and Clang.
2023-09-26 15:00:43 +03:00
Lasse Collin 9c42f93693 Build: Fix underquoted AC_LANG_SOURCE.
It made no practical difference in this case.
2023-09-26 13:51:31 +03:00
Lasse Collin 9f1444a8a5 Build: Silence two Autoconf warnings.
There were two uses of AC_COMPILE_IFELSE that didn't use
AC_LANG_SOURCE and Autoconf warned about these. 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
#define __EXTENSIONS__ 1 because it begins with two underscores.
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-09-26 13:50:19 +03:00
Jia Tan 519e47c281 CMake: Remove accidental extra newline. 2023-09-26 01:17:11 +08:00
Jia Tan bbb42412da Build: Remove Gnulib dependency from tests.
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-09-26 00:47:26 +08:00
Jia Tan d265f6b756 CMake: Remove /lib from tests include path.
The tests never included anything from /lib, so this was not needed.
2023-09-26 00:43:43 +08:00
Jia Tan 9fb5de41f2 Scripts: Change quoting style from `...' to '...'. 2023-09-24 22:10:41 +08:00
Jia Tan eaebdef4d4 xz: Change quoting style from `...' to '...'. 2023-09-24 22:10:18 +08:00
Jia Tan f6667702bf liblzma: Change quoting style from `...' to '...'.
This was done for both internal and API headers.
2023-09-24 22:09:47 +08:00
Jia Tan be012b8097 Build: Change quoting style from `...' to '...'. 2023-09-24 22:09:16 +08:00
Jia Tan ce162db07f Docs: Change quoting style from `...' to '...'.
These days the ` and ' do not look symmetric. This quoting style has
been changed in various apps over the years including the GNU tools.
2023-09-24 22:05:02 +08:00
Jia Tan db17656721 lib: Silence -Wsign-conversion in getopt.c. 2023-09-24 21:25:01 +08:00
Jia Tan a6234f677d Build: Update getopt.m4 from Gnulib.
This file was modified from upstream since we do not need to replace
getopt() and can avoid complexity and feature tests.
2023-09-24 20:48:52 +08:00
Jia Tan 84808b68f1 CMake: Add /lib to include path. 2023-09-26 00:09:53 +08:00
Jia Tan 01804a0b4b CMake: Update libgnu target with new header files. 2023-09-24 20:36:34 +08:00
Jia Tan d34558388f lib: Update Makefile.am for new header files. 2023-09-23 00:47:52 +08:00
Jia Tan 52bf644bdf lib: Update getopt1.c from Gnulib.
The only difference was maintaining the conditional inclusion for
config.h.
2023-09-24 20:34:03 +08:00
Jia Tan 7e884c00d0 lib: Update getopt.in.h from Gnulib with modifications.
We can still avoid modifying the contents of this file during
configuration to simplify the build systems. Gnulib added replacements
for inclusions guards for Cygwin. Cygwin should not need getopt_long
replacement so this feature can be omitted.

<unistd.h> is conditionally included to avoid MSVC since it is not
available.

The definition for _GL_ARG_NONNULL was also copied into this file from
Gnulib since this stage is usually done during gnulib-tool.
2023-09-23 03:27:00 +08:00
Jia Tan cff05f8206 lib: Update getopt_int.h from Gnulib. 2023-09-23 00:31:55 +08:00
Jia Tan 04bd86a4b0 lib: Update getopt.c from Gnulib with modifications.
The code maintains the prior modifications of conditionally including
config.h and disabling NLS support.

_GL_UNUSED is repalced with the simple cast to void trick. _GL_UNUSED
is only used for these two parameters so its simpler than having to
define it.
2023-09-23 00:27:23 +08:00
Jia Tan 56b42be728 lib: Add getopt-cdefs.h for getopt_long update.
This was modified slightly from Gnulib. In Gnulib, it expects the
@HAVE_SYS_CDEFS_H@ to be replaced. Instead, we can set HAVE_SYS_CDEFS_H
on systems that have it and avoid copying another file into the build
directory. Since we are not using gnulib-tool, copying extra files
requires extra build system updates (and special handling with CMake) so
we should avoid when possible.
2023-09-23 00:18:56 +08:00
Jia Tan 9834e591a4 lib: Copy new header files from Gnulib without modification.
The getopt related files have changed from Gnulib by splitting up
getopt.in.h into more modular header files. We could have kept
everything in just getopt.in.h, but this will help us continue to update
in the future.
2023-09-23 00:15:25 +08:00
Lasse Collin 5b7a6f06e9 Windows: Update the version requirement comments from Win95 to W2k. 2023-09-24 17:48:13 +03:00
Lasse Collin e582f8e0fe tuklib_physmem: Comment out support for Windows versions older than 2000. 2023-09-24 17:48:13 +03:00
Lasse Collin 7d73d1f0e0 sysdefs.h: Update the comment about __USE_MINGW_ANSI_STDIO. 2023-09-24 16:32:32 +03:00
Lasse Collin 2a9929af0a xz: Windows: Don't (de)compress to special files like "con" or "nul".
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-09-22 20:16:40 +03:00
Lasse Collin 01311b81f0 CMake: Wrap two overlong lines that are possible to wrap. 2023-09-22 20:10:10 +03:00
Lasse Collin 152d0771dd CMake: Add a comment about threads on Cygwin. 2023-09-22 20:10:10 +03:00
Lasse Collin 6df988ccef MSVC: Remove Visual Studio project files and update INSTALL-MSVC.txt.
CMake is now the preferred build file generator when building
with MSVC.
2023-09-22 20:10:10 +03:00
Lasse Collin edd563daf0 CMake: Require VS2015 or later for building xzdec.
xzdec might build with VS2013 but it hasn't been tested.
It was never supported before and VS2013 is old anyway
so for simplicity only liblzma is supported with VS2013.
2023-09-22 20:10:10 +03:00
Lasse Collin daea64d158 CMake: Allow building xz with Visual Studio 2015 and later.
Building the command line tools xz and xzdec with the combination
of CMake + Visual Studio 2015/2017/2019/2022 works now.

VS2013 update 2 should still be able to build liblzma.
VS2013 cannot build the xz command line tool because xz
needs snprintf() that roughly conforms to C99.
VS2013 is old and no extra code will be added to support it.

Thanks to Kelvin Lee and Jia Tan for testing.
2023-09-22 20:06:27 +03:00
Lasse Collin 8c2d197c94 MSVC: #define inline and restrict only when needed.
This also drops the check for _WIN32 as that shouldn't be needed.
2023-09-22 20:06:27 +03:00
Lasse Collin af66cd5859 CMake: Add support for replacement getopt_long (lib/getopt*).
Thanks to Jia Tan for the initial work. I added the libgnu target
and made a few related minor edits.
2023-09-22 20:06:27 +03:00
Lasse Collin e3288fdb45 CMake: Bump maximum policy version to 3.27.
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-09-22 20:06:27 +03:00
Lasse Collin aff1b479c7 lib/getopt*.c: Include <config.h> only HAVE_CONFIG_H is defined.
The CMake-based build doesn't use config.h.

Up-to-date getopt_long in Gnulib is LGPLv2 so at some
point it could be included in XZ Utils too but for now
this commit is enough to make CMake-based build possible.
2023-09-22 20:06:27 +03:00
Lasse Collin aa0cd585d2 Doxygen: Add more C macro names to PREDEFINED. 2023-09-22 20:06:27 +03:00
Lasse Collin ee7709bae5 liblzma: Move a few __attribute__ uses in function declarations.
The API headers have many attributes but these were left
as is for now.
2023-09-22 20:06:27 +03:00
Lasse Collin 217958d887 xz, xzdec, lzmainfo: Use tuklib_attr_noreturn.
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-09-22 20:06:27 +03:00
Lasse Collin 18a66fbac0 Remove incorrect uses of __attribute__((__malloc__)).
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-09-22 20:06:27 +03:00
Lasse Collin 74b0e900c9 Build: Omit -Wc99-c11-compat since it warns about _Noreturn. 2023-09-22 20:06:26 +03:00
Lasse Collin 90c94dddfd tuklib: Update tuklib_attr_noreturn for C11/C17 and C23.
This makes no difference for GCC or Clang as they support
GNU C's __attribute__((__noreturn__)) but this helps with MSVC:

  - VS 2019 version 16.7 and later support _Noreturn if the
    options /std:c11 or /std:c17 are used. This gets handled
    with the check for __STDC_VERSION__ >= 201112.

  - When MSVC isn't in C11/C17 mode, __declspec(noreturn) is used.

C23 will deprecate _Noreturn (and <stdnoreturn.h>)
for [[noreturn]]. This commit anticipates that but
the final __STDC_VERSION__ value isn't known yet.
2023-09-22 20:06:21 +03:00
Lasse Collin 189f725813 Update THANKS. 2023-09-22 20:00:38 +03:00
Lasse Collin 79334e7f20 MSVC: xz: Make file_io.c and file_io.h compatible with MSVC.
Thanks to Kelvin Lee for the original patches
and testing the modifications I made.
2023-09-22 20:00:38 +03:00
Lasse Collin c660b8d78b MSVC: xz: Use GetTickCount64() to implement mytime_now().
It's available since Windows Vista.
2023-09-22 20:00:38 +03:00
Kelvin Lee 5c6f892d41 MSVC: xz: Use _stricmp() instead of strcasecmp() in suffix.c. 2023-09-22 20:00:38 +03:00
Kelvin Lee e241051f50 MSVC: xz: Use _isatty() from <io.h> to implement isatty(). 2023-09-22 20:00:38 +03:00
Kelvin Lee d14bba8fc2 MSVC: xz: Use _fileno() instead of fileno(). 2023-09-22 20:00:38 +03:00
Kelvin Lee c4edd36767 MSVC: xzdec: Use _fileno and _setmode. 2023-09-22 20:00:37 +03:00
Kelvin Lee cfd1054b9b MSVC: Don't #include <unistd.h>. 2023-09-22 20:00:37 +03:00
Lasse Collin adef92f235 Update THANKS. 2023-09-19 14:03:45 +03:00
Jia Tan 953e775941 CI: Enable CLMUL in address sanitization test.
The crc64_clmul() function should be ignored by the address sanitizer
now so these builds should still pass.
2023-09-14 21:43:34 +08:00
Lasse Collin f167e79bc9 Update THANKS. 2023-09-14 16:35:46 +03:00
Lasse Collin 4f44ef8675 liblzma: Mark crc64_clmul() with __attribute__((__no_sanitize_address__)).
Thanks to Agostino Sarubbo.
Fixes: https://github.com/tukaani-project/xz/issues/62
2023-09-14 16:34:07 +03:00
Jia Tan 7379bb3eed CMake: Fix time.h checks not running on second CMake run.
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-09-12 22:49:03 +08:00
Jia Tan 5d691fe582 CMake: Fix unconditionally defining HAVE_CLOCK_MONOTONIC.
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-09-12 22:34:06 +08:00
Lasse Collin eccf128665 xz: Refactor thousand separator detection and disable it on MSVC.
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-08-31 19:50:05 +03:00
Lasse Collin f7093cd9d1 xz: Fix a too relaxed assertion and remove uses of SSIZE_MAX.
SSIZE_MAX isn't readily available on MSVC. Removing it means
that there is one thing less to worry when porting to MSVC.
2023-08-31 18:14:43 +03:00
Jia Tan 74c3449d8b Tests: Improve invalid unpadded size check in test_lzma_index_append().
This check was extended to test the code added to fix a failing assert
in ae5c07b22a.
2023-08-28 23:14:45 +08:00
Jia Tan 2544274a8b Tests: Improve comments in test_index.c. 2023-08-28 23:05:55 +08:00
Jia Tan 49be29d638 Update THANKS. 2023-08-28 23:05:46 +08:00
Jia Tan 721e3d9f7a liblzma: Update assert in vli_ceil4().
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-08-28 23:05:34 +08:00
Jia Tan ae5c07b22a liblzma: Add overflow check for Unpadded size in lzma_index_append().
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-08-28 23:04:56 +08:00
Jia Tan 1057765aaa Translations: Update the Esperanto translation. 2023-08-28 22:18:29 +08:00
Jia Tan f2e94d064f Translations: Update the Esperanto translation. 2023-08-26 20:10:23 +08:00
Jia Tan 2b871f4dbf Docs: Update INSTALL for --enable-threads method win95.
The Autotools build allows win95 threads and --enable-small together now
if the compiler supports __attribute__((__constructor__)).
2023-08-14 20:39:22 +08:00
Jia Tan 356ad5b26b CMake: Conditionally allow win95 threads and --enable-small. 2023-08-14 20:39:18 +08:00
Jia Tan de574404c4 Build: Conditionally allow win95 threads and --enable-small.
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-08-09 20:35:16 +08:00
Jamaika1 6bf33b704c
mythread.h: Fix typo error in Vista threads mythread_once().
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-08-08 20:07:59 +08:00
Jia Tan 80cb961e53 codespell: Add .codespellrc to set default options.
The .codespellrc allows setting default options to avoid false positive
matches, set additional dictionaries, etc. For now, codespell can be
used locally before committing doc and comment changes.

It should help prevent silly errors and fix up commits in the future.
2023-08-04 22:17:11 +08:00
Jia Tan cd678a6077 Tests: Style fixes to test_lzip_decoder.c. 2023-08-03 20:10:21 +08:00
Jia Tan 1cac5ed4fa Translations: Update the Chinese (simplified) translation. 2023-08-03 15:56:20 +08:00
Lasse Collin 16068f6c30 xz: Omit an empty paragraph on the man page. 2023-08-02 17:15:12 +03:00
Jia Tan 9ae4371b51 Add NEWS for 5.4.4. 2023-08-02 20:30:07 +08:00
Lasse Collin e8c2203b2c build-aux/manconv.sh: Fix US-ASCII and UTF-8 output.
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-02 15:19:43 +03:00
Lasse Collin 9a706167b0 Update THANKS. 2023-08-01 19:10:43 +03:00
Lasse Collin 33e25a0f56 Update THANKS. 2023-08-01 18:22:24 +03:00
ChanTsune 81db3b8898 mythread.h: Disable signal functions in builds targeting Wasm + WASI.
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-01 18:18:05 +03:00
Jia Tan 71c638c611 Add newline to end of .gitignore.
Newline was accidentally removed in commit
01cbb7f023.
2023-08-01 21:58:51 +08:00
Dimitri Papadopoulos Orfanos 42df7c7aa1
Docs: Fix typos found by codespell 2023-07-31 20:02:21 +08:00
Jia Tan 01cbb7f023 Update .gitignore. 2023-07-28 22:17:50 +08:00
Jia Tan f97a1afd56 CMake: Conditionally allow the creation of broken symlinks.
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
80a1a8bb83.
2023-07-28 22:03:08 +08:00
Jia Tan 7190f4cc7c CI: Fix windows-ci dependency installation.
All of the MSYS2 environments need make, and it does not come with the
toolchain package. The toolchain package will install the needed
compiler toolchains since without this package CMake cannot properly
generate the Makefiles.
2023-07-28 21:56:48 +08:00
Jia Tan a048f472cd CI: Update ci_build.sh CMake to always make Unix Makefiles.
The default for many of the MSYS2 environments is for CMake to create
Ninja build files. This would complicate the build script since we would
need a different command to run the tests. Its simpler to always use
Unix Makefiles so that "make test" is always a usable target for
testing.
2023-07-28 21:54:22 +08:00
Jia Tan 7870396a0c CI: Test CMake builds and test framework with MSYS2. 2023-07-25 20:17:23 +08:00
Jia Tan 6497d1f887 CI: Windows CI rename system matrix variable -> msys2_env.
Calling the MSYS2 environment "system" was a bit vague and should be
more specific.
2023-07-25 20:14:53 +08:00
Jia Tan 785e4121d9 CI: Add Clang64 MSYS2 environment to Windows CI. 2023-07-24 23:11:45 +08:00
Jia Tan d9166b52cf liblzma: Prevent an empty translation unit in Windows builds.
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-07-24 23:11:13 +08:00
Jia Tan db5019d691 Translations: Update the Vietnamese translation. 2023-07-22 18:37:56 +08:00
Jia Tan f3a055f762 CI: Add Windows runner for Autotools builds with MSYS2.
Only a subset of the tests run by the Linux and MacOS Autotools builds
are run. The most interesting tests are the ones that disable threads,
encoders, and decoders.

The Windows runner will only be run manually since these tests will
likely take much longer than the Linux and MacOS runners. This runner
should be used before merging any large features and before releases.

Currently the clang64 environment fails to due to a warning and
-Werror is enabled for the CI tests. This is still an early version
since the CMake build can be done for MSVC and optionally each of the
MSYS2 environments. GitHub does not allow manually running the CI tests
unless the workflow is checked on the default branch so checking in a
minimum version is a good idea.

Thanks to Arthur S for the original proposing the original patch.

Closes: https://github.com/tukaani-project/xz/pull/34
2023-07-22 18:31:02 +08:00
Jia Tan 556536a352 CI: Add argument to ci_build.sh to pass flags to autogen.sh. 2023-07-22 18:13:43 +08:00
Jia Tan 39a32d36fc Tests: Skip .lz files in test_files.sh if not configured.
Previously if the lzip decoder was not configured then test_files.sh
would pass the lzip tests instead of skipping them.
2023-07-21 18:05:44 +08:00
Jia Tan 194d12724b Tests: Add ARM64 filter test to test_compress.sh. 2023-07-20 22:11:13 +08:00
Jia Tan d850365c44 Translations: Update the Croatian translation. 2023-07-20 20:30:05 +08:00
Jia Tan 24049eb7ac Translations: Update the Korean man page translations. 2023-07-20 20:28:32 +08:00
Jia Tan 4d4a4fa07d Translations: Update the Korean translation. 2023-07-20 20:25:24 +08:00
Jia Tan 237f06d9c5 Translations: Update the Polish translation. 2023-07-20 20:24:05 +08:00
Jia Tan 80c2c83213 Translations: Update the German man page translations. 2023-07-20 20:22:23 +08:00
Jia Tan fdbde14503 Translations: Update the German translation. 2023-07-20 20:18:44 +08:00
Jia Tan 9f3bf5ff5b Translations: Update the Chinese (simplified) translation. 2023-07-20 20:17:10 +08:00
Jia Tan 376938c588 Translations: Update the Swedish translation. 2023-07-20 20:15:47 +08:00
Jia Tan 26b0bc6eb8 Translations: Update the Ukrainian man page translations. 2023-07-20 20:14:00 +08:00
Jia Tan 2d02c8b764 Translations: Update the Ukrainian translation. 2023-07-20 20:09:15 +08:00
Jia Tan f881018b50 Translations: Update the Spanish translation. 2023-07-20 20:06:57 +08:00
Jia Tan 791fe6d3ff Translations: Update the Romanian translation. 2023-07-20 20:05:19 +08:00
Jia Tan 8827e90704 Translations: Update the Romanian man page translations. 2023-07-20 20:02:56 +08:00
Jia Tan 0184d344fa liblzma: Suppress -Wunused-function warning.
Clang 16.0.0 and earlier have a bug that the ifunc resolver function
triggers the -Wunused-function warning. The resolver function is static
and only "used" by the __attribute__((__ifunc()__)).

At this time, the bug is still unresolved, but has been reported:
https://github.com/llvm/llvm-project/issues/63957

This is not a problem in GCC.
2023-07-19 23:36:00 +08:00
Jia Tan 43845fa70f liblzma: Reword lzma_str_list_filters() documentation.
This further improves the documentation from commit
f36ca7982f. The previous wording of
"supported options" was slightly misleading since the options that are
printed are the ones that are relevant for encoding/decoding. It is not
about which options can or must be specified.
2023-07-18 22:57:58 +08:00
Jia Tan 818701ba1c liblzma: Improve comment in string_conversion.c.
The comment used "flag" when referring to decoder options. Just
referring to them as options is more clear and consistent.
2023-07-18 22:56:47 +08:00
Lasse Collin b6b7d06585 xz: Translate the second "%s: " in message.c since French needs "%s : ".
This string is used to print a filename when using "xz -v" and
stderr isn't a terminal.
2023-07-18 17:37:33 +03:00
Lasse Collin be644042c3 xz: Make "%s: %s" translatable because French needs "%s : %s". 2023-07-18 17:34:18 +03:00
Lasse Collin 97fd5cb669 liblzma: Tweak #if condition in memcmplen.h.
Maybe ICC always #defines _MSC_VER on Windows but now
it's very clear which code will get used.
2023-07-18 13:57:54 +03:00
Lasse Collin 40392c19f7 liblzma: Omit unnecessary parenthesis in a preprocessor directive. 2023-07-18 13:49:43 +03:00
Jia Tan abc1d5601b xz: Update Authors list in a few files. 2023-07-18 00:51:48 +08:00
Jia Tan 289034a168 Docs: Add a new section to INSTALL for Tests.
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-18 00:45:31 +08:00
Jia Tan 1119e5f5a5 Docs: Update README.
This adds an entry to "Other implementations of the .xz format" for
XZ for Java.
2023-07-17 23:53:30 +08:00
Jia Tan f99e2e4e53 xz: Fix typo in man page.
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-17 23:34:55 +08:00
Jia Tan f907705eb1 xz: Minor clean up for coder.c
* Moved max_block_list_size from a global to local variable.
* Reworded error message in validate_block_list_filter().
* Removed helper function filter_chain_error().
* Changed 1 << X to 1U << X in many places
2023-07-17 23:34:55 +08:00
Jia Tan 9adc9e5615 xz: Update man page Authors and date. 2023-07-17 23:34:55 +08:00
Jia Tan c12e429f26 xz: Add a section to man page for robot mode --filters-help. 2023-07-17 23:34:55 +08:00
Jia Tan e10f2db5d1 xz: Slight reword in xz man page for consistency.
Changed will print => prints in xz --robot --version description to
match --robot --info-memory description.
2023-07-17 23:34:55 +08:00
Jia Tan f5dc172a40 xz: Reorder robot mode subsections in the man page.
The order is now consistent with the order the command line arguments
are documented earlier in the man page. The new order is:
1. --list
2. --info-memory
3. --version

Instead of the previous order:
1. --version
2. --info-memory
3. --list
2023-07-17 23:34:55 +08:00
Jia Tan 9628be23ae xz: Update man page for new --filters-help option. 2023-07-17 23:34:55 +08:00
Jia Tan a165d7df19 xz: Add a new --filters-help option.
The --filters-help can be used to help create filter chains with the
--filters and --filtersX options. The message in --long-help is too
short to fully explain the syntax to construct complex filter chains.

In --robot mode, xz will only print the output from liblzma function
lzma_str_list_filters.
2023-07-17 23:34:55 +08:00
Jia Tan 95f1a414b1 xz: Update the man page for --block-list and --filtersX
The --block-list option description needed updating since the new
--filtersX option changes how it can be used. The new entry for
--filters1=FILTERS ... --filter9=FILTERS was created right after
the --filters option.
2023-07-17 23:34:55 +08:00
Jia Tan 47a63cad2a xz: Update --long-help for the new --filtersX option. 2023-07-17 23:34:55 +08:00
Jia Tan 8b9913a13d xz: Ignore filter chains that are set but never used in --block-list.
If a filter chain is set but not used in --block-list, it introduced
unexpected behavior such as requiring an unneeded amount of memory to
compress, reducing the number of threads in multi-threaded encoding, and
printing an incorrect amount of memory needed to decompress.

This also renames filters_init_mask => filters_used_mask. A filter is
assumed to be used if it is specified in --filtersX until
coder_set_compression_settings() determines which filters are referenced
in --block-list.
2023-07-17 23:34:55 +08:00
Jia Tan 183819bfd9 xz: Set the Block size for mt encoding correctly.
When opt_block_size is not used, the Block size for mt encoder is
derived from the minimum of the largest Block specified by
--block-list and the recommended Block size on all filter chains
calculated by lzma_mt_block_size(). This avoids using unnecessary
memory and ensures that all Blocks are large enough for the most memory
needy filter chain.
2023-07-17 23:34:55 +08:00
Jia Tan afb2dbec3d xz: Validate --flush-timeout for all specified filter chains. 2023-07-17 23:34:55 +08:00
Jia Tan 5f0c5a0438 xz: Allows --block-list filters to scale down memory usage.
Previously, only the default filter chain could have its memory usage
adjusted. The filter chains specified with --filtersX were not checked
for memory usage. Now, all used filter chains will be adjusted if
necessary.
2023-07-17 23:34:55 +08:00
Jia Tan 479fd58d60 xz: Do not include block splitting if encoders are disabled.
The block splitting logic and split_block() function are not needed if
encoders are disabled. This will help slightly reduce the binary size
when built without encoders and allow split_block() to use functions
that require encoders being enabled.
2023-07-17 23:34:55 +08:00
Jia Tan f86ede2250 xz: Free filters[] in debug mode.
This will only free filter chains created with --filters1-9 since the
default filter chain may be set from a static function variable. The
complexity to free the default filter chain is not worth the burden on
code maintenance.
2023-07-17 23:34:55 +08:00
Jia Tan f281cd0d69 xz: Add a message if --block-list is used outside of xz compresssion.
--block-list is only supported with compression in xz format. This avoids
silently ignoring when --block-list is unused.
2023-07-17 23:34:55 +08:00
Jia Tan d6af7f3470 xz: Create command line options for filters[1-9].
The new command line options are meant to be combined with --block-list.
They work as an optional extension to --block-list to specify a custom
filter chain for each block listed. The new options allow the creation
of up to 9 reusable filter chains. For instance:

xz --block-list=1:10MiB,3:5MiB,,2:5MiB,1:0 --filters1=delta--lzma2 \
--filters2=x86--lzma2 --filters3=arm64--lzma2

Will create the following blocks:
1. A block of size 10 MiB with filter chain delta, lzma2.
2. A block of size 5 MiB with filter chain arm64, lzma2.
3. A block of size 5 MiB with filter chain arm64, lzma2.
4. A block of size 5 MiB with filter chain x86, lzma2.
5. A block containing the rest of the file contents with filter chain
   delta, lzma2.
2023-07-17 23:34:55 +08:00
Jia Tan 072d292501 xz: Use lzma_filters_free() in forget_filter_chain().
This is a little cleaner than the previous implementation of
forget_filter_chain(). It is also more consistent since
lzma_str_to_filters() will always terminate the filter chain so there
is no need to terminate it later in coder_set_compression_settings().
2023-07-17 23:34:55 +08:00
Jia Tan 3d21da5cff xz: Separate string to filter conversion into a helper function.
Converting from string to filter will also need to be done for block
specific filter chains.
2023-07-17 23:34:55 +08:00
Jia Tan a6583726e5 Tests: Use new --filters option in test_compress.sh 2023-07-17 23:34:55 +08:00
Jia Tan 5f3b898d07 xz: Update --long-help and man page for new --filters option. 2023-07-17 23:34:55 +08:00
Jia Tan 9ded880a02 xz: Add --filters option to CLI.
The --filters option uses the new lzma_str_to_filters() function
to convert a string into a full filter chain. Using this option
will reset all previous filters set by --preset, --[filter], or
--filters.
2023-07-17 23:34:55 +08:00
Jia Tan 2c189bb00a Tests: Improve feature testing for skipping.
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-14 21:30:25 +08:00
Jia Tan 80a6b9bcad Translations: Update the Chinese (traditional) translation. 2023-07-10 20:56:28 +08:00
Jia Tan 17f8844e6f liblzma: Remove non-portable empty initializer.
Commit 78704f36e7 added an empty
initializer {} to prevent a warning. The empty initializer is a GNU
extension and results in a build failure on MSVC. The -wpedantic flag
warns about empty initializers.
2023-07-08 21:24:19 +08:00
Jia Tan 3aca4f629c Translations: Update the Vietnamese translation. 2023-07-08 20:03:59 +08:00
Jia Tan 66bdcfa85f Tests: Fix memory leaks in test_index.
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-06-29 00:07:16 +08:00
Jia Tan fe3bd438fb Tests: Fix memory leaks in test_block_header.
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-06-29 00:07:05 +08:00
Jia Tan 78704f36e7 liblzma: Prevent uninitialzed warning in mt stream encoder.
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-06-29 00:06:16 +08:00
Jia Tan e3356a204c liblzma: Prevent warning for MSYS2 Windows build.
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-06-28 23:59:51 +08:00
Jia Tan 45e250a9e9 CI: Add test with -fsanitize=address,undefined.
ci_build.sh was updated to accept disabling of __attribute__ ifunc
and CLMUL. This will allow -fsanitize=address to pass because ifunc
is incompatible with -fsanitize=address. The CLMUL implementation has
optimizations that potentially read past the buffer and mask out the
unwanted bytes.

This test will only run on Autotools Linux.
2023-06-28 23:59:47 +08:00
Jia Tan 596ee722cd CI: Upgrade checkout action from v2 to v3. 2023-06-28 20:48:49 +08:00
Jia Tan 86118ea320 Update THANKS. 2023-06-27 23:56:06 +08:00
Jia Tan 3d1fdddf92 Docs: Document the configure option --disable-ifunc in INSTALL. 2023-06-27 23:56:06 +08:00
Lasse Collin b4cf7a2822 Minor tweaks to style and comments. 2023-06-27 23:56:06 +08:00
Lasse Collin 23fb9e3a32 CMake: Rename CHECK_ATTR_IFUNC to ALLOW_ATTR_IFUNC.
It's so that there's a clear difference in wording compared
to liblzma's integrity check types.
2023-06-27 23:56:06 +08:00
Lasse Collin ee44863ae8 liblzma: Add ifunc implementation to crc64_fast.c.
The ifunc method avoids indirection via the function pointer
crc64_func. This works on GNU/Linux and probably on FreeBSD too.
The previous __attribute((__constructor__)) method is kept for
compatibility with ELF platforms which do support ifunc.

The ifunc method has some limitations, for example, building
liblzma with -fsanitize=address will result in segfaults.
The configure option --disable-ifunc must be used for such builds.

Thanks to Hans Jansen for the original patch.
Closes: https://github.com/tukaani-project/xz/pull/53
2023-06-27 23:55:59 +08:00
Hans Jansen b72d212024 Add ifunc check to CMakeLists.txt
CMake build system will now verify if __attribute__((__ifunc__())) can be
used in the build system. If so, HAVE_FUNC_ATTRIBUTE_IFUNC will be
defined to 1.
2023-06-27 15:33:15 +03:00
Hans Jansen 23b5c36fb7 Add ifunc check to configure.ac
configure.ac will now verify if __attribute__((__ifunc__())) can be used in
the build system. If so, HAVE_FUNC_ATTRIBUTE_IFUNC will be defined to 1.
2023-06-27 15:33:15 +03:00
Jia Tan dbb3a536ed CI: Add apt update command before installing dependencies.
Without the extra command, all of the CI tests were automatically
failing because the Ubuntu servers could not be reached properly.
2023-06-07 00:23:02 +08:00
Jia Tan 6bcd516812 Update THANKS. 2023-06-07 00:10:38 +08:00
Benjamin Buch 0d94ba6922
CMake: Protects against double find_package
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 "ZLIB::ZLIB" 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-06-06 21:32:45 +08:00
Jia Tan 045d7aae28 Translations: Update the Esperanto translation. 2023-05-31 23:57:57 +08:00
Jia Tan b0cc7c2dce Translations: Update the Croatian translation. 2023-05-31 23:57:57 +08:00
Jia Tan af045ef6f8 Translations: Update the Chinese (simplified) translation. 2023-05-31 20:15:53 +08:00
Jia Tan e6b92d5817 Translations: Update German translation of man pages. 2023-05-17 23:12:13 +08:00
Jia Tan 592961ccdb Translations: Update the German translation. 2023-05-17 23:09:18 +08:00
Jia Tan 13572cb2c3 Translations: Update the Croatian translation. 2023-05-17 20:30:01 +08:00
Jia Tan 4e6e425ea8 Translations: Update Korean translation of man pages. 2023-05-17 20:26:54 +08:00
Jia Tan d5ef1f6faf Translations: Update the Korean translation. 2023-05-17 20:13:01 +08:00
Jia Tan e22d0b0f2e Translations: Update the Spanish translation. 2023-05-16 23:49:09 +08:00
Jia Tan f50da74d52 Translations: Update the Romanian translation. 2023-05-16 23:47:23 +08:00
Jia Tan 4b9ad60a73 Translations: Update Romanian translation of man pages. 2023-05-16 23:45:43 +08:00
Jia Tan cb6fd57f88 Translations: Update Ukrainian translation of man pages. 2023-05-16 23:44:45 +08:00
Jia Tan c3e8fcbc2d Translations: Update the Ukrainian translation. 2023-05-16 23:44:45 +08:00
Jia Tan 27b81b84fc Translations: Update the Polish translation. 2023-05-16 23:44:36 +08:00
Jia Tan 8024ad636a Translations: Update the Swedish translation. 2023-05-16 22:52:14 +08:00
Jia Tan 6699a29673 Translations: Update the Esperanto translation. 2023-05-16 21:21:38 +08:00
Jia Tan f36ca7982f liblzma: Slightly rewords lzma_str_list_filters() documentation.
Reword "options required" to "supported options". The previous may have
suggested that the options listed were all required anytime a filter is
used for encoding or decoding. The reword makes this more clear that
adjusting the options is optional.
2023-05-13 21:21:54 +08:00
Jia Tan 3374a5359e liblzma: Adds lzma_nothrow to MicroLZMA API functions.
None of the liblzma functions may throw an exception, so this
attribute should be applied to all liblzma API functions.
2023-05-12 00:00:47 +08:00
Jia Tan 8f23657498 liblzma: Exports lzma_mt_block_size() as an API function.
The lzma_mt_block_size() was previously just an internal function for
the multithreaded .xz encoder. It is used to provide a recommended Block
size for a given filter chain.

This function is helpful to determine the maximum Block size for the
multithreaded .xz encoder when one wants to change the filters between
blocks. Then, this determined Block size can be provided to
lzma_stream_encoder_mt() in the lzma_mt options parameter when
intializing the coder. This requires one to know all the filter chains
they are using before starting to encode (or at least the filter chain
that will need the largest Block size), but that isn't a bad limitation.
2023-05-11 23:54:44 +08:00
Jia Tan d0f33d672a liblzma: Creates IS_ENC_DICT_SIZE_VALID() macro.
This creates an internal liblzma macro to test if the dictionary size
is valid for encoding.
2023-05-11 22:28:45 +08:00
Jia Tan c247d06e1f Add NEWS for 5.4.3. 2023-05-04 22:15:35 +08:00
Jia Tan 77050b7836 Add NEWS for 5.2.12. 2023-05-04 22:15:30 +08:00
Jia Tan 713e15e43e Translations: Update the Croatian translation. 2023-05-04 20:38:52 +08:00
Jia Tan 9ad64bdf30 tuklib_integer.h: Reverts previous commit.
Previous commit 6be460dde0 would cause an
error if the integer size was 32 bit.
2023-05-04 20:30:25 +08:00
Jia Tan 6be460dde0 tuklib_integer.h: Changes two other UINT_MAX == UINT32_MAX to >=. 2023-05-04 19:25:20 +08:00
Lasse Collin 44c0c5eae9 tuklib_integer.h: Fix a recent copypaste error in Clang detection.
Wrong line was changed in 7062348bf3.
Also, this has >= instead of == since ints larger than 32 bits would
work too even if not relevant in practice.
2023-05-03 22:55:16 +03:00
Jia Tan 2cf5ae5b5b CI: Adds a build and test for small configuration. 2023-04-25 22:14:28 +08:00
Jia Tan 16b81a057a CI: ci_build.sh allows configuring small build. 2023-04-25 20:05:26 +08:00
Jia Tan 78ccd93951 Update THANKS. 2023-04-20 20:15:00 +08:00
Jia Tan f41df2ac2f Windows: Include <intrin.h> when needed.
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-19 22:22:16 +08:00
Jia Tan 7062348bf3 tuklib_integer: Use __builtin_clz() with Clang.
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-19 21:59:03 +08:00
Lasse Collin 3938718ce3 liblzma: Update project maintainers in lzma.h.
AUTHORS was updated earlier, lzma.h was simply forgotten.
2023-04-14 18:42:33 +03:00
Jia Tan 2a89670ab2 liblzma: Cleans up old commented out code. 2023-04-13 20:45:19 +08:00
Jia Tan 0fbb2b87a7 Docs: Add missing word to SECURITY.md. 2023-04-07 20:46:41 +08:00
Jia Tan fb9c50f38a Update THANKS. 2023-04-07 20:43:56 +08:00
Jia Tan 537c6cd8a9 Docs: Minor edits to SECURITY.md. 2023-04-07 20:43:56 +08:00
Gabriela Gutierrez 6549df8dd5 Docs: Create SECURITY.md
Signed-off-by: Gabriela Gutierrez <gabigutierrez@google.com>
2023-04-07 20:43:49 +08:00
Jia Tan d0faa85df5 CI: Tests for disabling threading on CMake builds. 2023-03-29 23:46:43 +08:00
Jia Tan 8be5cc3b13 CI: Removes CMakeCache.txt between builds.
If the cache file is not removed, CMake will not reset configurations
back to their default values. In order to make the tests independent, it
is simplest to purge the cache. Unfortunatly, this will slow down the
tests a little and repeat some checks.
2023-03-29 23:46:43 +08:00
Jia Tan 2cb6028fc3 CMake: Update liblzma-config.cmake generation.
Now that the threading is configurable, the liblzma CMake package only
needs the threading library when using POSIX threads.
2023-03-29 23:46:38 +08:00
Jia Tan 4d7fac0b07 CMake: Allows setting thread method.
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-03-29 23:24:12 +08:00
Jia Tan 20cd905d89 CI: Runs CMake feature tests.
Now, CMake will run similar feature disable tests that the Autotools
version did before. In order to do this without repeating lines in
ci.yml, it now makes sense to use the GitHub Workflow matrix to create
a loop.
2023-03-24 23:41:06 +08:00
Jia Tan 4fabdb269f CI: ci_build.sh allows CMake features to be configured.
Also included various clean ups for style and helper functions for
repeated work.
2023-03-24 23:08:24 +08:00
Jia Tan cf3d1f130e CI: Change ci_build.sh to use bash instead of sh.
This script is only meant to be run as part of the CI build/test process
on machines that are known to have bash (Ubuntu and MacOS). If this
assumption changes in the future, then the bash specific commands will
need to be replaced with a more portable option. For now, it is
convenient to use bash commands.
2023-03-24 20:06:33 +08:00
Jia Tan ddfe164368 CMake: Only build xzdec if decoders are enabled. 2023-03-24 20:05:59 +08:00
Jia Tan 116e81f002 Build: Removes redundant check for LZMA1 filter support. 2023-03-23 21:48:52 +08:00
Lasse Collin 0ba234f692 CMake: Bump maximum policy version to 3.26.
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-03-23 21:48:52 +08:00
Jia Tan b0891684b4 CMake: Conditionally build xz list.* files if decoders are enabled. 2023-03-23 21:48:52 +08:00
Jia Tan 2c1a830efb CMake: Allow configuring features as cache variables.
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-23 21:48:52 +08:00
Lasse Collin 8be136f667 Build: Add a comment that AC_PROG_CC_C99 is needed for Autoconf 2.69.
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-21 14:07:51 +02:00
Lasse Collin 53cc475f26 Build: configure.ac: Use AS_IF and AS_CASE where required.
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 5a5bd7f871.
2023-03-21 14:04:37 +02:00
Lasse Collin 3b8890a402 Update THANKS. 2023-03-21 13:12:03 +02:00
Lasse Collin 5a5bd7f871 Build: Fix --disable-threads breaking the building of shared libs.
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 6629ed929c 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-21 13:11:49 +02:00
Lasse Collin dfe1710784 liblzma: Silence -Wsign-conversion in SSE2 code in memcmplen.h.
Thanks to Christian Hesse for reporting the issue.
Fixes: https://github.com/tukaani-project/xz/issues/44
2023-03-19 22:45:59 +02:00
Jia Tan f0c580c5fc Add NEWS for 5.4.2. 2023-03-18 22:23:39 +08:00
Jia Tan af4925e604 Add NEWS for 5.2.11. 2023-03-18 22:10:12 +08:00
Lasse Collin 5a7b930efa Update the copy of GNU GPLv3 from gnu.org to COPYING.GPLv3. 2023-03-18 16:00:54 +02:00
Lasse Collin b473a92891 Change a few HTTP URLs to HTTPS.
The xz man page timestamp was intentionally left unchanged.
2023-03-18 15:56:07 +02:00
Jia Tan 8b2f6001b4 CMake: Fix typo in a comment. 2023-03-18 00:40:28 +08:00
Lasse Collin 76e2315e14 Windows: build.bash: Copy liblzma API docs to the output package. 2023-03-17 18:36:22 +02:00
Lasse Collin 133cf55edc Windows: Add microlzma_*.c to the VS project files.
These should have been included in 5.3.2alpha already.
2023-03-17 08:53:38 +02:00
Lasse Collin 75c9ca450f CMake: Add microlzma_*.c to the build.
These should have been included in 5.3.2alpha already.
2023-03-17 08:43:51 +02:00
Lasse Collin 0cc3313bd4 Build: Update comments about unaligned access to mention 64-bit. 2023-03-17 08:41:36 +02:00
Lasse Collin 5e57e33013 Tests: Update .gitignore. 2023-03-17 00:02:34 +02:00
Lasse Collin 0007394d54 po4a/update-po: Display the script name consistently in error messages. 2023-03-17 00:02:34 +02:00
Jia Tan 509157c80c Doc: Rename Doxygen HTML doc directory name liblzma => api.
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-17 01:42:28 +08:00
Jia Tan fd90e2f4c2 liblzma: Remove note from lzma_options_bcj about the ARM64 exception.
This was left in by mistake since an early version of the ARM64 filter
used a different struct for its options.
2023-03-17 01:42:28 +08:00
Jia Tan 4f50763b98 CI: Add doxygen as a dependency.
Autogen now requires --no-doxygen or having doxygen installed to run
without errors.
2023-03-17 01:42:28 +08:00
Lasse Collin f68f4b27f6 COPYING: Add a note about the included Doxygen-generated HTML. 2023-03-17 01:42:28 +08:00
Jia Tan 8979308528 Doc: Update PACKAGERS with details about liblzma API docs install. 2023-03-17 01:42:28 +08:00
Jia Tan 55ba6e9300 liblzma: Add set lzma.h as the main page for Doxygen documentation.
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-17 01:42:28 +08:00
Jia Tan 16f2125559 Build: Generate doxygen documentation in autogen.sh.
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-17 01:42:28 +08:00
Jia Tan 1321852a3b Build: Create doxygen/update-doxygen script.
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-17 01:42:28 +08:00
Jia Tan b1216a7772 Build: Install Doxygen docs and include in distribution if generated.
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-17 01:42:28 +08:00
Lasse Collin c97d12f300 Doxygen: Refactor Doxyfile.in to doxygen/Doxyfile.
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-17 01:42:28 +08:00
Jia Tan 1b7661faa4 Tests: Remove unused macros and functions. 2023-03-13 20:49:53 +08:00
Jia Tan af55191102 liblzma: Defines masks for return values from lzma_index_checks(). 2023-03-13 20:49:53 +08:00
Jia Tan 8f38cdd9ab Tests: Refactors existing lzma_index tests.
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-13 20:49:53 +08:00
Lasse Collin 717aa3651c xz: Simplify the error-label in Capsicum sandbox code.
Also remove unneeded "sandbox_allowed = false;" as this code
will never be run more than once (making it work with multiple
input files isn't trivial).
2023-03-11 18:46:45 +02:00
Lasse Collin a0eecc235d xz: Make Capsicum sandbox more strict with stdin and stdout. 2023-03-08 23:22:15 +08:00
Jia Tan 916448d624 Revert: "Add warning if Capsicum sandbox system calls are unsupported."
The warning causes the exit status to be 2, so this will cause problems
for many scripted use cases for xz. The sandbox usage is already very
limited already, so silently disabling this allows it to be more usable.
2023-03-08 23:22:11 +08:00
Jia Tan 01587dda2a xz: Fix -Wunused-label in io_sandbox_enter().
Thanks to Xin Li for recommending the fix.
2023-03-07 20:02:22 +08:00
Jia Tan 5fb9367866 xz: Add warning if Capsicum sandbox system calls are unsupported.
The warning is only used when errno == ENOSYS. Otherwise, xz still
issues a fatal error.
2023-03-06 21:37:45 +08:00
Jia Tan 61ee82cb12 xz: Skip Capsicum sandbox system calls when they are unsupported.
If a system has the Capsicum header files but does not actually
implement the system calls, then this would render xz unusable. Instead,
we can check if errno == ENOSYS and not issue a fatal error.
2023-03-06 21:27:53 +08:00
Jia Tan f070722b57 xz: Reorder cap_enter() to beginning of capsicum sandbox code.
cap_enter() puts the process into the sandbox. If later calls to
cap_rights_limit() fail, then the process can still have some extra
protections.
2023-03-06 21:08:26 +08:00
Jia Tan f1ab1f6b33 liblzma: Clarify lzma_lzma_preset() documentation in lzma12.h.
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-01 21:42:31 +08:00
Lasse Collin 4b7fb3bf41 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
2023-02-27 18:38:35 +02:00
Jia Tan 9aa7fdeb04 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.
2023-02-24 21:11:18 +08:00
Jia Tan 3cf72c4bcb liblzma: Replace '\n' -> newline in filter.h documentation.
The '\n' renders as a newline when the comments are converted to html
by Doxygen.
2023-02-24 21:09:39 +08:00
Jia Tan 002006be62 liblzma: Shorten return description for two functions in filter.h.
Shorten the description for lzma_raw_encoder_memusage() and
lzma_raw_decoder_memusage().
2023-02-24 21:09:39 +08:00
Jia Tan 463d9359b8 liblzma: Reword a few lines in filter.h 2023-02-24 21:09:39 +08:00
Jia Tan 01441df92c 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.
2023-02-24 21:09:39 +08:00
Lasse Collin 805b45cd60 Update THANKS. 2023-02-23 20:46:16 +02:00
Lasse Collin 30e95bb44c 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
2023-02-23 20:41:22 +02:00
Jia Tan fa9065fac5 liblzma: Adjust container.h for consistency with filter.h. 2023-02-23 20:27:59 +08:00
Jia Tan 00a721b63d liblzma: Fix small typos and reword a few things in filter.h. 2023-02-23 20:27:59 +08:00
Jia Tan 5b1c171d4f liblzma: Convert list of flags in lzma_mt to bulleted list. 2023-02-23 20:27:59 +08:00
Jia Tan dbd47622eb liblzma: Fix typo in documentation in container.h
lzma_microlzma_decoder -> lzma_microlzma_encoder
2023-02-23 20:27:59 +08:00
Jia Tan 14cd30806d 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.
2023-02-23 20:27:59 +08:00
Jia Tan c9c8bfae35 CMake: Add LZIP decoder test to list of tests. 2023-02-22 21:10:28 +08:00
Lasse Collin b9f171dd00 Update THANKS. 2023-02-17 20:56:49 +02:00
Lasse Collin 2ee86d20e4 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
2023-02-17 20:48:28 +02:00
Lasse Collin d831072cce 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.
2023-02-16 21:09:00 +02:00
Jia Tan f029daea39 liblzma: Adjust spacing in doc headers in bcj.h. 2023-02-17 00:54:33 +08:00
Jia Tan a5de68bac2 liblzma: Adjust documentation in bcj.h for consistent style. 2023-02-17 00:49:47 +08:00
Jia Tan efa498c13b liblzma: Rename field => member in documentation.
Also adjusted preset value => preset level.
2023-02-17 00:49:47 +08:00
Lasse Collin 718b22a6c5 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.
2023-02-16 17:59:50 +02:00
Jia Tan 87c53553fa 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.
2023-02-16 21:04:54 +08:00
Jia Tan 13d99e75a5 liblzma: Improve documentation in lzma12.h.
All functions now explicitly specify parameter and return values.
2023-02-15 22:21:44 +08:00
Jia Tan 43ec344c86 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.
2023-02-15 00:59:16 +08:00
Jia Tan 9c71db4e88 liblzma: Improve documentation in index.h
All functions now explicitly specify parameter and return values.
2023-02-15 00:20:44 +08:00
Jia Tan 421f2f2e16 liblzma: Reword a comment in index.h. 2023-02-15 00:20:44 +08:00
Jia Tan b675394849 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.
2023-02-15 00:20:44 +08:00
Jia Tan 0c9e4fc2ad liblzma: Fix documentation for LZMA_MEMLIMIT_ERROR.
LZMA_MEMLIMIT_ERROR was missing the "<" character needed to put
documentation after a member.
2023-02-14 20:41:05 +08:00
Jia Tan 816fec125a liblzma: Improve documentation for base.h.
Standardizing each function to always specify params and return values.
Also fixed a small grammar mistake.
2023-02-14 20:41:05 +08:00
Jia Tan 862dacef1a liblzma: Add one more missing [out] annotation in vli.h 2023-02-14 00:12:34 +08:00
Jia Tan 867b08ae42 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.
2023-02-14 00:08:33 +08:00
Jia Tan 90d0e628ff 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.
2023-02-10 21:38:25 +08:00
Jia Tan 9255fffdb1 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.
2023-02-10 21:35:23 +08:00
Lasse Collin 1dbe12b90c xz: Improve the comment about start_time in mytime.c.
start_time is relative to an arbitary point in time, it's not
time of day, so using it for anything else than time differences
wouldn't make sense.
2023-02-07 19:07:45 +02:00
Jia Tan 7673ef5aa8 Build: Adjust CMake version search regex.
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-02-04 21:06:35 +08:00
Jia Tan b8bce89be7 xz: Add a comment clarifying the use of start_time in mytime.c. 2023-02-04 20:11:51 +08:00
Jia Tan 912af91b10 liblzma: Improve documentation for version.h.
Specified parameter and return values for API functions and documented
a few more of the macros.
2023-02-04 20:11:36 +08:00
Jia Tan 850adec171 Docs: Omit SIGTSTP not handled from TODO. 2023-02-03 22:52:55 +08:00
Jia Tan 2c78a83c6f 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.
2023-02-03 00:42:27 +08:00
Jia Tan e01f01b9af Tests: Create test_filter_str.c.
Tests lzma_str_to_filters(), lzma_str_from_filters(), and
lzma_str_list_filters() API functions.
2023-02-03 00:42:27 +08:00
Jia Tan 8dfc029e7a liblzma: Fix typos in comments in string_conversion.c. 2023-02-03 00:42:27 +08:00
Jia Tan 54ad83c1ae 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.
2023-02-03 00:22:53 +08:00
Jia Tan f680e771b3 Update lzma_block documentation for lzma_block_uncomp_encode(). 2023-02-03 00:22:53 +08:00
Jia Tan 504cf4af89 liblzma: Minor edits to lzma_block header_size documentation. 2023-02-03 00:22:53 +08:00
Jia Tan 115b720fb5 liblzma: Enumerate functions that read version in lzma_block. 2023-02-03 00:22:53 +08:00
Jia Tan 85ea0979ad liblzma: Clarify comment in block.h. 2023-02-03 00:22:53 +08:00
Jia Tan 1f7ab90d9c 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 00:22:53 +08:00
Jia Tan c563a4bc55 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-01 23:39:45 +08:00
Jia Tan 315c64c7e1 CI: Update .gitignore for artifacts directory in build-aux.
The workflow action for our CI pipeline can only reference artifacts in
the source directory, so we should ignore these files if the ci_build.sh
is run locally.
2023-02-01 21:47:35 +08:00
Jia Tan 2c1341f4fa CI: Add quotes around variables in a few places. 2023-02-01 21:47:35 +08:00
Jia Tan 3a401b0e0c CI: Upload test logs as artifacts if a test fails. 2023-02-01 21:47:35 +08:00
Lasse Collin 610dde15a8 xz: Use clock_gettime() even if CLOCK_MONOTONIC isn't available.
mythread.h and thus liblzma already does it.
2023-01-27 20:02:49 +02:00
Lasse Collin 2e02877288 po4a/po4a.conf: Sort the language identifiers in alphabetical order. 2023-01-27 19:41:19 +02:00
Lasse Collin ff592c616e xz: Add SIGTSTP handler for progress indicator time keeping.
This way, if xz is stopped the elapsed time and estimated time
remaining won't get confused by the amount of time spent in
the stopped state.

This raises SIGSTOP. It's not clear to me if this is the correct way.
POSIX and glibc docs say that SIGTSTP shouldn't stop the process if
it is orphaned but this commit doesn't attempt to handle that.

Search for SIGTSTP in section 2.4.3:

https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html
2023-01-27 19:37:47 +02:00
Jia Tan 3b1c8ac8d1 Translations: Add Brazilian Portuguese translation of man pages.
Thanks to Rafael Fontenelle.
2023-01-27 20:16:54 +08:00
Lasse Collin a15a7552f9 Build: Avoid different quoting style in --enable-doxygen doc. 2023-01-26 17:51:06 +02:00
Lasse Collin af5a4bd5af tuklib_physmem: Check for __has_warning before GCC version.
Clang can be configured to fake a too high GCC version so
this way it's more robust.
2023-01-26 17:39:46 +02:00
Jia Tan f35d98e206 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-01-24 20:48:50 +08:00
Lasse Collin 2f78ecc593 Revert "tuklib_common: Define __has_warning if it is not defined."
This reverts commit 82e3c968bf.

Macros in the reserved namespace (_foo or __foo) shouldn't be #defined
without a very good reason. Here the alternative would have been
to #define tuklib_has_warning(str) to an approriate value.

Also the tuklib_* files should stay namespace clean if possible.
2023-01-24 20:20:51 +08:00
Lasse Collin 8366cf8738 tuklib_physmem: Clean up the way -Wcast-function-type is silenced on Windows.
__has_warning and other __has_foo macros are meant to become
compiler-agnostic so it's not good to check for __clang__ with it.

This also relied on tuklib_common.h for #defining __has_warning
which was confusing as #defining reserved macros is generally
not a good idea.
2023-01-24 20:20:40 +08:00
Lasse Collin 683a3c7e2f xz: Flip the return value of suffix_is_set to match the documentation.
Also edit style to match the existing coding style in the project.
2023-01-24 20:20:04 +08:00
Jia Tan cc5aa9ab13 xz: Refactor duplicated check for custom suffix when using --format=raw 2023-01-21 22:10:51 +08:00
Jia Tan 9663141274 liblzma: Set documentation on all reserved fields to private.
This prevents the reserved fields from being part of the generated
Doxygen documentation.
2023-01-21 21:37:48 +08:00
Jia Tan 6327a045f3 Doxygen: Update Doxyfile.in from 1.4.7 to 1.8.17.
A few Doxygen tags were obsolete from 1.4.7. Version 1.8.17 released
in 2019, so this should be compatible with resonable modern distros.
The purpose of Doxygen these days is for docs on the website, so it
doesn't necessarily have to work for everyone. Just when the maintainers
want to update the docs.
2023-01-20 00:51:12 +08:00
Jia Tan bbf71b69eb Doxygen: Make Doxygen only produce liblzma API documentation by default.
Doxygen is now configurable in autotools only with
--enable-doxygen=[api|all]. The default is "api", which will only
generate HTML output for liblzma API functions. The LaTex documentation
output was also disabled.
2023-01-20 00:51:12 +08:00
Jia Tan 6fcf4671b6 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-01-20 00:51:12 +08:00
Jia Tan b43ff180fb 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-01-19 20:35:09 +08:00
Jia Tan 82e3c968bf tuklib_common: Define __has_warning if it is not defined.
clang supports the __has_warning macro to determine if the version of
clang compiling the code supports a given warning. If we do not define
it for other compilers, it may cause a preprocessor error.
2023-01-19 20:32:40 +08:00
Jia Tan b2ba1a489d CI: Reorder 32-bit build first for Linux autotool builds.
The 32-bit build needs to be first so the configure cache only needs to
be reset one time. The 32-bit build sets the CFLAGS env variable, so any
build using that flag after will fail unless the cache is reset.
2023-01-18 22:11:05 +08:00
Jia Tan dd1c113574 CI: Enable --config-cache in autotool builds.
If CFLAGS are set in a build, the cache must be cleared with
"make distclean", or by deleting the cache file.
2023-01-18 21:51:43 +08:00
Jia Tan d3e1147705 xz: Add missing comment for coder_set_compression_settings() 2023-01-16 21:35:45 +08:00
Jia Tan 123255b6ed 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-01-16 20:55:10 +08:00
Jia Tan 571919c47b Translations: Update the Brazilian Portuguese translation. 2023-01-13 22:21:49 +08:00
Jia Tan 81cb02e2c2 CI: Disable shared and nls from various jobs in autotool runners.
Disabling shared library generation and linking should help speed up the
runners. The shared library is still being tested in the 32 bit build
and the full feature.

Disabling nls is to check for any unexpected warnings or errors.
2023-01-12 23:43:06 +08:00
Jia Tan 58a052198a CI: Reorder the 32-bit job in the Ubuntu runner.
Run the 32 bit job sooner since this is a more interesting test than
some of the later jobs.
2023-01-12 23:39:19 +08:00
Jia Tan 4110a998b8 CI: Allow disabling Native Language Support. 2023-01-12 23:09:03 +08:00
Jia Tan 0dec634e70 CI: Only run autogen.sh if it has not already run. 2023-01-12 23:02:20 +08:00
Jia Tan 32287dc8de CI: Allow disabling shared library in autotools builds. 2023-01-12 22:58:36 +08:00
Jia Tan 77d1ebcc99 CI: Improve Usage readability and add -h option. 2023-01-12 22:44:18 +08:00
Lasse Collin a8bb8358d1 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-01-12 13:04:05 +02:00
Lasse Collin 52dc033d0b 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-01-12 06:05:58 +02:00
Lasse Collin b1a6d180a3 xz: Silence warnings from -Wsign-conversion in a 32-bit build. 2023-01-12 06:01:12 +02:00
Lasse Collin 31c21c734b 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-01-12 05:38:48 +02:00
Lasse Collin 37fbdfb726 liblzma: Silence a warning from -Wsign-conversion in a 32-bit build. 2023-01-12 04:46:45 +02:00
Lasse Collin 5ce6ddc221 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-01-12 04:17:24 +02:00
Lasse Collin bfc3a0a8ac 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-01-12 04:14:18 +02:00
Lasse Collin 49245bb31e 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-01-12 03:56:24 +02:00
Lasse Collin 3f13bf6b9e 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-01-12 03:19:59 +02:00
Lasse Collin 6c886cc5b3 Fix warnings from clang -Wdocumentation. 2023-01-12 03:11:40 +02:00
Lasse Collin a0e7fb1c1e Tests: test_lzip_decoder: Remove trailing white-space. 2023-01-12 03:04:28 +02:00
Lasse Collin c0f8d6782f Tests: test_lzip_decoder: Silence warnings from -Wsign-conversion. 2023-01-12 03:03:55 +02:00
Jia Tan 62efd48a82
Add NEWS for 5.4.1. 2023-01-11 23:58:16 +08:00
Jia Tan d1561c47ec
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 22:46:48 +08:00
Jia Tan 8c0f115cc4 Tests: Fix test_filter_flags copy/paste error. 2023-01-11 20:58:31 +08:00
Jia Tan 25035813d1 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 20:42:29 +08:00
Lasse Collin 0b8fa310cf 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-10 22:15:55 +02:00
Jia Tan 765354b50c 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 01:18:50 +08:00
Jia Tan 7c23c05bef 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 01:08:03 +08:00
Jia Tan 57464bb4eb CI/CD: Add 32-bit build and test steps to Ubuntu autotools runner.
If all goes well, Mac autotools and Linux and Mac CMake will be added
later for 32-bit builds.
2023-01-11 00:54:45 +08:00
Jia Tan 923eb689a4 CI/CD: Enables warnings as errors in autotool build.
This will help us catch warnings and potential bugs in builds that are
not often tested by us.
2023-01-11 00:51:01 +08:00
Jia Tan feae5528a3 CI/CD: Add -f argument to set CFLAGS in ci_build.sh.
For now, the suggested option is for -m32 only, but this can be updated
later if other flags are deemed useful.
2023-01-11 00:48:35 +08:00
Lasse Collin cfabb62a48 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:47:16 +02:00
Lasse Collin 0b64215170 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-10 11:56:11 +02:00
Lasse Collin ec2fc39fe4 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-10 11:23:41 +02:00
Lasse Collin 7049c4a76c sysdefs.h: Fix a comment. 2023-01-10 10:05:13 +02:00
Lasse Collin 194a5fab69 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:04:06 +02:00
Lasse Collin 5e34774c31 CMake: Fix appending to CMAKE_RC_FLAGS.
It's a string, not a list. It only worked when the variable was empty.

Thanks to Iouri Kharon.
2023-01-10 08:29:32 +02:00
Lasse Collin 6e652ceb18 Windows: Update INSTALL-MSVC.txt to recommend CMake over project files. 2023-01-10 00:35:09 +02:00
Lasse Collin 6b117d3b1f CMake: Fix windres issues again.
At least on some systems, GNU windres needs --use-temp-file
in addition to the \x20 hack to avoid spaces in the command line
argument. Hovever, that \x20 syntax is broken with llvm-windres
version 15.0.0 (results in "XZx20Utils") but luckily it works
with a regular space. Thus it is best to limit the workarounds
to GNU toolchain on Windows.
2023-01-09 23:41:25 +02:00
Lasse Collin 0c210ca7f4 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 20:35:20 +08:00
Jia Tan 5c9fdd3bf5 Tests: Refactors existing filter flags tests.
Converts the existing filter flags tests into tuktests.
2023-01-09 20:35:20 +08:00
Lasse Collin 36edc65ab4 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 12:22:05 +02:00
Lasse Collin 790a12a95a 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 11:27:24 +02:00
Lasse Collin 0e1545fea3 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-08 00:32:29 +02:00
Lasse Collin 69d5d78c69 Update THANKS. 2023-01-08 00:24:23 +02:00
Lasse Collin dd38655f80 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-08 00:20:42 +02:00
Lasse Collin a890a637be Update THANKS. 2023-01-08 00:20:42 +02:00
Lasse Collin 6e38e595dd 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-08 00:20:42 +02:00
Lasse Collin 443dfebced CMake/Windows: Add a workaround for windres from GNU binutils.
Thanks to Iouri Kharon for the bug report and the original patch.
2023-01-08 00:20:42 +02:00
Lasse Collin ceb8050117 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-08 00:20:42 +02:00
Jia Tan 8d372bd940 CI/CD: Split CMake Linux and MacOS build phase to build and test.
The phase split was only done for Autotools before, so should also
apply to CMake.
2023-01-07 21:15:18 +08:00
Jia Tan 747c7f2b34 CI/CD: Reduce job runners to 4 instead of using matrix strategy.
The old version used too many runners that resulted in unnecessary
dependency downloads. Now, the runners are reused for the different
configurations for each OS and build system.
2023-01-07 21:15:16 +08:00
Jia Tan 4de35fd6b5 CI/CD: Add new -p (PHASE) argument to ci_build.sh
The new PHASE argument can be build, test, or all. all is the default.
This way, the CI/CD script can differentiate between the build and test
phases to make it easier to track down errors when they happen.
2023-01-07 21:15:14 +08:00
Jia Tan 6fd39664de
Merge pull request #7 from tukaani-project/tuktest_index_hash
Tuktest index hash
2023-01-07 00:10:50 +08:00
Lasse Collin fc0c788469 Tests: test_index_hash: Add an assert_uint_eq(). 2023-01-06 17:58:48 +02:00
Lasse Collin d550304f53 Tests: test_index_hash: Fix a memory leak. 2023-01-06 17:55:06 +02:00
Lasse Collin 02608f74ea Tests: test_index_hash: Don't treat pointers as booleans. 2023-01-06 17:53:03 +02:00
Lasse Collin 056766c860 Tests: test_index_hash: Fix a typo in a comment. 2023-01-06 17:51:41 +02:00
Lasse Collin 873e684028 Tests: test_index_hash: Avoid the variable name "index".
It can trigger warnings from -Wshadow on some systems.
2023-01-06 17:44:29 +02:00
Lasse Collin d1f24c3587 Tests: test_index_hash: Use the word "Record" instead of "entry". 2023-01-06 17:35:50 +02:00
Lasse Collin b93f7c5cbb Tests: test_index_hash: Tweak comments and style.
The words defined in the .xz file format specification
begin with capital letter to emphasize that they have
a specific meaning.
2023-01-06 17:35:05 +02:00
Lasse Collin c48b24fc06 Tests: test_index_hash: Use INDEX_INDICATOR constant instead of 0. 2023-01-06 17:17:37 +02:00
Jia Tan 78e0561dfe Style: Change #if !defined() to #ifndef in mythread.h. 2023-01-06 20:43:31 +08:00
Jia Tan e834e1e934 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.
2023-01-06 20:42:18 +08:00
Jia Tan 84f9687cba 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 common.h will redefine
LZMA_API resulting in a warning.
2023-01-05 20:57:25 +08:00
Lasse Collin 7657ce1c3c Update THANKS. 2023-01-04 23:16:26 +02:00
Lasse Collin aafd67fba0 Tests: Adjust style in test_compress.sh. 2023-01-04 18:40:28 +02:00
Jia Tan 52380678f4
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.
2023-01-04 23:58:58 +08:00
Jia Tan d0eb345bb7 Translations: Add Korean translation of man pages.
Thanks to Seong-ho Cho
2023-01-03 21:02:38 +08:00
Jia Tan c4145978d9 Translations: Update the Esperanto translation. 2023-01-03 20:47:27 +08:00
Lasse Collin 4103a2e78a Bump version and soname for 5.5.0alpha.
5.5.0alpha won't be released, it's just to mark that
the branch is not for stable 5.4.x.

Once again there is no API/ABI stability for new features
in devel versions. The major soname won't be bumped even
if API/ABI of new features breaks between devel releases.
2023-01-02 17:20:47 +02:00
Lasse Collin 73c9e6d6b9 Build: Fix config.h comments. 2023-01-02 17:05:07 +02:00
Jia Tan bb740e3b11
Build: Only define HAVE_PROGRAM_INVOCATION_NAME if it is set to 1.
HAVE_DECL_PROGRAM_INVOCATION_NAME is renamed to
HAVE_PROGRAM_INVOCATION_NAME. Previously,
HAVE_DECL_PROGRAM_INVOCATION_NAME was always set when
building with autotools. CMake would only set this when it was 1, and the
dos/config.h did not define it. The new macro definition is consistent
across build systems.
2023-01-02 22:33:48 +08:00
Jia Tan 064cd385a7 Adds test_index_hash to .gitignore. 2023-01-02 22:20:04 +08:00
Jia Tan 3959162bae 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.
2023-01-02 22:20:04 +08:00
Jia Tan f16e12d5e7 liblzma: Add NULL check to lzma_index_hash_append.
This is for consistency with lzma_index_append.
2023-01-02 22:20:04 +08:00
Jia Tan 203b008eb2 liblzma: Replaced hardcoded 0x0 index indicator byte with macro 2023-01-02 22:20:04 +08:00
Lasse Collin dfecda8752 Tests: test_check: Test corner cases of CLMUL CRC64. 2022-12-30 20:10:08 +02:00
Lasse Collin ce96bb2043 Tests: Clarify a comment in test_lzip_decoder.c. 2022-12-30 19:36:49 +02:00
Jia Tan 2fcba17fc4 xz: Includes <time.h> and <sys/time.h> conditionally in mytime.c.
Previously, mytime.c depended on mythread.h for <time.h> to be included.
2022-12-30 23:34:31 +08:00
Jia Tan f82294c831 liblzma: Includes sys/time.h conditionally in mythread
Previously, <sys/time.h> was always included, even if mythread only used
clock_gettime. <time.h> is still needed even if clock_gettime is not used
though because struct timespec is needed for mythread_condtime.
2022-12-30 23:34:31 +08:00
Jia Tan 74dae7d300 Build: No longer require HAVE_DECL_CLOCK_MONOTONIC to always be set.
Previously, if threading was enabled HAVE_DECL_CLOCK_MONOTONIC would always
be set to 0 or 1. However, this macro was needed in xz so if xz was not
built with threading and HAVE_DECL_CLOCK_MONOTONIC was not defined but
HAVE_CLOCK_GETTIME was, it caused a warning during build. Now,
HAVE_DECL_CLOCK_MONOTONIC has been renamed to HAVE_CLOCK_MONOTONIC and
will only be set if it is 1.
2022-12-30 23:34:31 +08:00
Jia Tan 7339e39dc0 Translations: Add Ukrainian translations of man pages.
Thanks to Yuri Chornoivan
2022-12-30 23:34:31 +08:00
Jia Tan 9f05c27a58 CI/CD: Create initial version of CI/CD workflow.
The CI/CD workflow will only execute on Ubuntu and MacOS latest version.
The workflow will attempt to build with autotools and CMake and execute
the tests. The workflow will run for all pull requests and pushes done
to the master branch.
2022-12-30 23:34:31 +08:00
Jia Tan 1275ebfba7 liblzma: Update documentation for lzma_filter_encoder. 2022-12-30 23:34:31 +08:00
Jia Tan 7c9ff5f166 Tests: Adds lzip decoder tests 2022-12-30 23:34:31 +08:00
Jia Cheong Tan 799ead162d Doxygen: Update .gitignore for generating docs for in source build.
In source builds are not recommended, but we should still ignore
the generated artifacts.
2022-12-30 23:34:31 +08:00
Jia Tan 5f7ce42a16 liblzma: Fix lzma_microlzma_encoder() return value.
Using return_if_error on lzma_lzma_lclppb_encode was improper because
return_if_error is expecting an lzma_ret value, but
lzma_lzma_lclppb_encode returns a boolean. This could result in
lzma_microlzma_encoder, which would be misleading for applications.
2022-12-30 23:34:31 +08:00
Jia Tan 8ace358d65 CMake: Update .gitignore for CMake artifacts from in source build.
In source builds are not recommended, but we can make it easier
by ignoring the generated artifacts from CMake.
2022-12-30 23:34:31 +08:00
Lasse Collin 8fd225a2c1 liblzma: Update authors list in arm64.c. 2022-12-16 18:30:02 +02:00
Lasse Collin b69da6d4bb Bump version to 5.4.0 and soname to 5.4.0. 2022-12-13 20:46:41 +02:00
Lasse Collin 20869eb3fb Update INSTALL: CMake on Windows isn't experimental anymore.
Using CMake to build liblzma should work on a few other OSes
but building the command line tools is still subtly broken.

It is known that shared library versioning may differ between
CMake and Libtool builds on some OSes, most notably Darwin.
2022-12-13 20:29:39 +02:00
Lasse Collin cbbd844519 Add NEWS for 5.4.0. 2022-12-13 20:27:39 +02:00
Lasse Collin c3e94d37e8 Fix a typo in NEWS. 2022-12-13 17:41:20 +02:00
Lasse Collin 0d2a2e0a54 Add NEWS for 5.2.10. 2022-12-13 17:41:03 +02:00
Lasse Collin 177ece1c8e Tests: Fix a typo in tests/files/README. 2022-12-13 12:30:45 +02:00
Lasse Collin 60f45bdbaa Tests: Add two ARM64 test files. 2022-12-13 12:30:09 +02:00
Lasse Collin f5e4195506 Translations: Update the Catalan translation. 2022-12-12 22:44:21 +02:00
Lasse Collin 0fb9d355da Update THANKS. 2022-12-12 19:18:12 +02:00
Lasse Collin e5b6c161c6 Update AUTHORS. 2022-12-12 19:07:58 +02:00
Lasse Collin f2d98e6910 Docs: Omit multi-threaded decompress from TODO.
The TODO file outdated still.
2022-12-12 15:31:14 +02:00
Lasse Collin b42908c42a Docs: Update xz-file-format.txt to 1.1.0 for ARM64 filter. 2022-12-11 21:16:09 +02:00
Lasse Collin 854f2f5946 xz: Rename --experimental-arm64 to --arm64. 2022-12-11 21:13:57 +02:00
Lasse Collin 31dbd1e5fb liblzma: Change LZMA_FILTER_ARM64 to the official Filter ID 0x0A. 2022-12-11 21:13:06 +02:00
Lasse Collin 01b3549e52 xz: Make args_info.files_name a const pointer. 2022-12-08 19:24:22 +02:00
Lasse Collin bc665b84ea xz: Don't modify argv[].
The code that parses --memlimit options and --block-list modified
the argv[] when parsing the option string from optarg. This was
visible in "ps auxf" and such and could be confusing. I didn't
understand it back in the day when I wrote that code. Now a copy
is allocated when modifiable strings are needed.
2022-12-08 19:18:16 +02:00
Lasse Collin a13064e1c2 Translations: Update the German man page translations. 2022-12-08 18:18:57 +02:00
Jia Tan 8bdbe42a8d Translations: Update the German translation. 2022-12-08 18:18:06 +02:00
Jia Tan 5c304b57c2 Translations: Update the Turkish translation. 2022-12-08 18:18:06 +02:00
Jia Tan 6d86781fdb Translations: Update the Croatian translation. 2022-12-08 18:18:06 +02:00
Jia Tan 7a5b4b8075 Translations: Add Romanian translation of man pages.
Thanks to Remus-Gabriel Chelu.
2022-12-08 18:18:06 +02:00
Jia Tan c6977e7400 Translations: Update the Romanian translation. 2022-12-08 18:18:06 +02:00
Lasse Collin ac2a747e93 liblzma: Check for unexpected NULL pointers in block_header_decode().
The API docs gave an impression that such checks are done
but they actually weren't done. In practice it made little
difference since the calling code has a bug if these are NULL.

Thanks to Jia Tan for the original patch that checked for
block->filters == NULL.
2022-12-08 17:30:09 +02:00
Lasse Collin 24790f49ae Bump version number for 5.3.5beta.
This also sorts the symbol names alphabetically in liblzma_*.map.
2022-12-01 20:59:32 +02:00
Lasse Collin 7e53c5bcb3 Add NEWS for 5.3.5beta. 2022-12-01 20:57:26 +02:00
Lasse Collin 5865f2aaac Update THANKS. 2022-12-01 20:57:09 +02:00
Lasse Collin 62b270988e liblzma: Use __has_attribute(__symver__) to fix Clang detection.
If someone sets up Clang to define __GNUC__ to 10 or greater
then symvers broke. __has_attribute is supported by such GCC
and Clang versions that don't support __symver__ so this should
be much better and simpler way to detect if __symver__ is
actually supported.

Thanks to Tomasz Gajc for the bug report.
2022-12-01 20:55:21 +02:00
Lasse Collin f9ca7d4516 liblzma: Omit zero-skipping from ARM64 filter.
It has some complicated downsides and its usefulness is more limited
than I originally thought. So this change is bad for certain very
specific situations but a generic solution that works for other
filters (and is otherwise better too) is planned anyway. And this
way 7-Zip can use the same compatible filter for the .7z format.

This is still marked as experimental with a new temporary Filter ID.
2022-12-01 18:55:00 +02:00
Lasse Collin 5baec3f0a9 xz: Omit the special notes about ARM64 filter on the man page. 2022-12-01 18:13:27 +02:00
Lasse Collin 0c3627b518 liblzma: Don't be over-specific in lzma_str_to_filters API doc. 2022-12-01 18:12:03 +02:00
Lasse Collin 94adf057f2 liblzma: Silence unused variable warning when BCJ filters are disabled.
Thanks to Jia Tan for the original patch.
2022-12-01 17:54:23 +02:00
Lasse Collin c68af44417 Translations: Update the Chinese (simplified) translation. 2022-12-01 17:38:03 +02:00
Lasse Collin 3be6942e5c Add NEWS for 5.2.9. 2022-11-30 18:55:03 +02:00
Jia Tan 7c16e312cb xz: Remove message_filters_to_str function prototype from message.h.
This was forgotten from 7484744af6.
2022-11-30 18:12:35 +02:00
Lasse Collin 764955e2d4 Change the bug report address.
It forwards to me and Jia Tan.

Also update the IRC reference in README as #tukaani was moved
to Libera Chat long ago.
2022-11-30 18:08:34 +02:00
Lasse Collin c21983c760 Build: Add string_conversion.c to CMake, DOS, and VS files. 2022-11-30 17:50:17 +02:00
Lasse Collin 30be0c35d2 Update to HTTPS URLs in AUTHORS. 2022-11-30 17:38:32 +02:00
Jia Tan 0a72b9ca2f liblzma: Improve documentation for string to filter functions. 2022-11-29 22:29:15 +02:00
Lasse Collin a6e21fcede liblzma: Two fixes to lzma_str_list_filters() API docs.
Thanks to Jia Tan.
2022-11-29 22:27:42 +02:00
Lasse Collin 7484744af6 xz: Use lzma_str_from_filters().
Two uses: Displaying encoder filter chain when compressing with -vv,
and displaying the decoder filter chain in --list -vv.
2022-11-28 22:05:32 +02:00
Lasse Collin cedeeca2ea liblzma: Add lzma_str_to_filters, _from_filters, and _list_filters.
lzma_str_to_filters() uses static error messages which makes
them not very precise. It tells the position in the string
where an error occurred though which helps quite a bit if
applications take advantage of it. Dynamic error messages can
be added later with a new flag if it seems important enough.
2022-11-28 21:54:24 +02:00
Lasse Collin 072ebf7b13 liblzma: Make lzma_validate_chain() available outside filter_common.c. 2022-11-28 21:02:19 +02:00
Lasse Collin 5f22bd2d37 liblzma: Remove lzma_lz_decoder_uncompressed() as it's now unused. 2022-11-28 10:51:03 +02:00
Lasse Collin cee8320646 liblzma: Use LZMA1EXT feature in lzma_microlzma_decoder().
Here too this avoids the slightly ugly method to set
the uncompressed size.

Also moved the setting of dict_size to the struct initializer.
2022-11-28 10:48:53 +02:00
Lasse Collin e310e8b6a4 liblzma: Use LZMA1EXT feature in lzma_alone_decoder().
This avoids the need to use the slightly ugly method to
set the uncompressed size.
2022-11-28 10:28:20 +02:00
Lasse Collin 33b8a24b66 liblzma: Add LZMA_FILTER_LZMA1EXT to support LZMA1 without end marker.
Some file formats need support for LZMA1 streams that don't use
the end of payload marker (EOPM) alias end of stream (EOS) marker.
So far liblzma API has supported decompressing such streams via
lzma_alone_decoder() when .lzma header specifies a known
uncompressed size. Encoding support hasn't been available in the API.

Instead of adding a new LZMA1-only API for this purpose, this commit
adds a new filter ID for use with raw encoder and decoder. The main
benefit of this approach is that then also filter chains are possible,
for example, if someone wants to implement support for .7z files that
use the x86 BCJ filter with LZMA1 (not BCJ2 as that isn't supported
in liblzma).
2022-11-27 23:16:21 +02:00
Lasse Collin 9a304bf1e4 liblzma: Avoid unneeded use of void pointer in LZMA decoder. 2022-11-27 18:43:07 +02:00
Lasse Collin 218394958c liblzma: Pass the Filter ID to LZ encoder and decoder.
This allows using two Filter IDs with the same
initialization function and data structures.
2022-11-27 18:20:33 +02:00
Lasse Collin 1663c7676b liblzma: Remove two FIXME comments. 2022-11-27 01:03:16 +02:00
Lasse Collin 11fe708db7 xz: Use lzma_filters_free(). 2022-11-26 22:25:30 +02:00
Lasse Collin e782af9110 liblzma: Use lzma_filters_free() in more places. 2022-11-26 22:21:13 +02:00
Lasse Collin 90caaded2d liblzma: Omit simple coder init functions if they are disabled. 2022-11-25 18:04:37 +02:00
Lasse Collin 5cd9f0df78 xz: Allow nice_len 2 and 3 even if match finder requires 3 or 4.
Now that liblzma accepts these, we avoid the extra check and
there's one message less for translators too.
2022-11-24 23:24:59 +02:00
Lasse Collin 3be88ae071 liblzma: Allow nice_len 2 and 3 even if match finder requires 3 or 4.
That is, if the specified nice_len is smaller than the minimum
of the match finder, silently use the match finder's minimum value
instead of reporting an error. The old behavior is annoying to users
and it complicates xz options handling too.
2022-11-24 23:23:55 +02:00
Lasse Collin 93439cfafe liblzma: Add lzma_filters_update() support to the multi-threaded encoder.
A tiny downside of this is that now a 1-4 tiny allocations are made
for every Block because each worker thread needs its own copy of
the filter chain.
2022-11-24 16:25:10 +02:00
Lasse Collin 17ac51e689 Update THANKS. 2022-11-24 14:53:22 +02:00
Lasse Collin 06824396b2 Build: Don't put GNU/Linux-specific symbol versions into static liblzma.
It not only makes no sense to put symbol versions into a static library
but it can also cause breakage.

By default Libtool #defines PIC if building a shared library and
doesn't define it for static libraries. This is documented in the
Libtool manual. It can be overriden using --with-pic or --without-pic.
configure.ac detects if --with-pic or --without-pic is used and then
gives an error if neither --disable-shared nor --disable-static was
used at the same time. Thus, in normal situations it works to build
both shared and static library at the same time on GNU/Linux,
only --with-pic or --without-pic requires that only one type of
library is built.

Thanks to John Paul Adrian Glaubitz from Debian for reporting
the problem that occurred on ia64:
https://www.mail-archive.com/xz-devel@tukaani.org/msg00610.html
2022-11-24 14:52:44 +02:00
Lasse Collin e1acf71072 liblzma: Refactor to use lzma_filters_free().
lzma_filters_free() sets the options to NULL and ids to
LZMA_VLI_UNKNOWN so there is no need to do it by caller;
the filter arrays will always be left in a safe state.

Also use memcpy() instead of a loop to copy a filter chain
when it is known to be safe to copy LZMA_FILTERS_MAX + 1
(even if the elements past the terminator might be uninitialized).
2022-11-24 01:32:16 +02:00
Lasse Collin cb05dbcf8b liblzma: Fix another invalid free() after memory allocation failure.
This time it can happen when lzma_stream_encoder_mt() is used
to reinitialize an existing multi-threaded Stream encoder
and one of 1-4 tiny allocations in lzma_filters_copy() fail.

It's very similar to the previous bug
10430fbf38, happening with
an array of lzma_filter structures whose old options are freed
but the replacement never arrives due to a memory allocation
failure in lzma_filters_copy().
2022-11-24 01:26:37 +02:00
Jia Tan 75f1a6c26d liblzma: Add support for LZMA_SYNC_FLUSH in the Block encoder.
The documentation mentions that lzma_block_encoder() supports
LZMA_SYNC_FLUSH but it was never added to supported_actions[]
in the internal structure. Because of this, LZMA_SYNC_FLUSH could
not be used with the Block encoder unless it was the next coder
after something like stream_encoder() or stream_encoder_mt().
2022-11-24 01:07:32 +02:00
Lasse Collin d090164517 liblzma: Add new API function lzma_filters_free().
This is small but convenient and should have been added
a long time ago.
2022-11-24 01:02:50 +02:00
Lasse Collin ae1f8a723d CMake: Don't use symbol versioning with static library. 2022-11-24 00:02:31 +02:00
Lasse Collin 48c1b99dc5 liblzma: Add lzma_attr_warn_unused_result to lzma_filters_copy(). 2022-11-23 21:55:22 +02:00
Lasse Collin 10430fbf38 liblzma: Fix invalid free() after memory allocation failure.
The bug was in the single-threaded .xz Stream encoder
in the code that is used for both re-initialization and for
lzma_filters_update(). To trigger it, an application had
to either re-initialize an existing encoder instance with
lzma_stream_encoder() or use lzma_filters_update(), and
then one of the 1-4 tiny allocations in lzma_filters_copy()
(called from stream_encoder_update()) must fail. An error
was correctly reported but the encoder state was corrupted.

This is related to the recent fix in
f8ee61e74e which is good but
it wasn't enough to fix the main problem in stream_encoder.c.
2022-11-23 21:26:21 +02:00
Lasse Collin cafd6dc397 liblzma: Fix language in a comment. 2022-11-22 16:37:15 +02:00
Lasse Collin c392bf8ccb liblzma: Fix infinite loop in LZMA encoder init with dict_size >= 2 GiB.
The encoder doesn't support dictionary sizes larger than 1536 MiB.
This is validated, for example, when calculating the memory usage
via lzma_raw_encoder_memusage(). It is also enforced by the LZ
part of the encoder initialization. However, LZMA encoder with
LZMA_MODE_NORMAL did an unsafe calculation with dict_size before
such validation and that results in an infinite loop if dict_size
was 2 << 30 or greater.
2022-11-22 11:23:23 +02:00
Lasse Collin f50534c973 liblzma: Fix two Doxygen commands in the API headers.
These were caught by clang -Wdocumentation.
2022-11-21 13:02:33 +02:00
Lasse Collin 649d4872ed xz: Refactor duplicate code from hardware_memlimit_mtenc_get(). 2022-11-19 19:09:55 +02:00
Lasse Collin d327743bb5 xz: Add support --threads=+N so that -T+1 gives threaded mode. 2022-11-19 19:06:13 +02:00
Jia Tan a11a2b8b5e CMake: Adds test_memlimit to CMake tests 2022-11-19 17:35:38 +02:00
Lasse Collin 2af8d9e9b3 Translations: Update the Korean translation. 2022-11-15 19:10:21 +02:00
Lasse Collin 16ac056772 Translations: Update the Turkish translation. 2022-11-15 19:09:28 +02:00
Lasse Collin b9a67d9a5f Bump version number for 5.3.4alpha. 2022-11-15 11:18:28 +02:00
Lasse Collin 5b999ba289 Add NEWS for 5.3.4alpha. 2022-11-15 10:58:19 +02:00
Lasse Collin ce8db9e37d Add NEWS for 5.2.8. 2022-11-15 10:54:08 +02:00
Lasse Collin b56bc8251d Revert "liblzma: Simple/BCJ filters: Allow disabling generic BCJ options."
This reverts commit 177bdc922c
and also does equivalent change to arm64.c.

Now that ARM64 filter will use lzma_options_bcj, this change
is not needed anymore.
2022-11-14 23:19:57 +02:00
Lasse Collin 8370ec8edf Replace the experimental ARM64 filter with a new experimental version.
This is incompatible with the previous version.

This has space/tab fixes in filter_*.c and bcj.h too.
2022-11-14 23:16:38 +02:00
Lasse Collin f644473a21 liblzma: Add fast CRC64 for 32/64-bit x86 using SSSE3 + SSE4.1 + CLMUL.
It also works on E2K as it supports these intrinsics.

On x86-64 runtime detection is used so the code keeps working on
older processors too. A CLMUL-only build can be done by using
-msse4.1 -mpclmul in CFLAGS and this will reduce the library
size since the generic implementation and its 8 KiB lookup table
will be omitted.

On 32-bit x86 this isn't used by default for now because by default
on 32-bit x86 the separate assembly file crc64_x86.S is used.
If --disable-assembler is used then this new CLMUL code is used
the same way as on 64-bit x86. However, a CLMUL-only build
(-msse4.1 -mpclmul) won't omit the 8 KiB lookup table on
32-bit x86 due to a currently-missing check for disabled
assembler usage.

The configure.ac check should be such that the code won't be
built if something in the toolchain doesn't support it but
--disable-clmul-crc option can be used to unconditionally
disable this feature.

CLMUL speeds up decompression of files that have compressed very
well (assuming CRC64 is used as a check type). It is know that
the CLMUL code is significantly slower than the generic code for
tiny inputs (especially 1-8 bytes but up to 16 bytes). If that
is a real-world problem then there is already a commented-out
variant that uses the generic version for small inputs.

Thanks to Ilya Kurdyukov for the original patch which was
derived from a white paper from Intel [1] (published in 2009)
and public domain code from [2] (released in 2016).

[1] https://www.intel.com/content/dam/www/public/us/en/documents/white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf
[2] https://github.com/rawrunprotected/crc
2022-11-14 23:05:46 +02:00
Lasse Collin 3b466bc796 Translations: Update the Swedish translation one more time. 2022-11-14 20:14:34 +02:00
Lasse Collin e963379a86 Translations: Update the Swedish translation again. 2022-11-14 19:34:15 +02:00
Lasse Collin a4bc689a82 Translations: Update the Swedish translation. 2022-11-14 19:07:45 +02:00
Lasse Collin bbf2073d82 Translations: Update the Ukrainian translation. 2022-11-14 18:58:09 +02:00
Lasse Collin ac10b1b362 Build: Omit x86_64 from --enable-assembler.
It didn't do anything. There are only 32-bit x86 assembly files
and it feels likely that new files won't be added as intrinsics
in C are more portable across toolchains and OSes.
2022-11-14 17:58:07 +02:00
Lasse Collin eb0f1450ad liblzma: Use __attribute__((__constructor__)) if available.
This uses it for CRC table initializations when using --disable-small.
It avoids mythread_once() overhead. It also means that then
--disable-small --disable-threads is thread-safe if this attribute
is supported.
2022-11-14 16:00:52 +02:00
Lasse Collin 6553f49b11 Translations: Update the Romanian translation. 2022-11-12 21:19:52 +02:00
Lasse Collin db97e69e12 Translations: Update the Hungarian translation. 2022-11-12 21:17:45 +02:00
Lasse Collin 2bbb9c0f38 Translations: Update the Finnish translation. 2022-11-11 17:58:57 +02:00
Lasse Collin 3c8cbb8137 Translations: Update the Croatian translation. 2022-11-11 17:58:18 +02:00
Lasse Collin 26c3359eac Translations: Update the Polish translation. 2022-11-11 17:57:18 +02:00
Lasse Collin 577e467b13 Translations: Update the Spanish translation. 2022-11-11 17:56:44 +02:00
Lasse Collin f9b4ff6e9a Update THANKS. 2022-11-11 17:16:03 +02:00
Lasse Collin a39961ef21 liblzma: Fix building with Intel ICC (the classic compiler).
It claims __GNUC__ >= 10 but doesn't support __symver__ attribute.

Thanks to Stephen Sachs.
2022-11-11 17:15:25 +02:00
Lasse Collin c715f683dc liblzma: Fix incorrect #ifdef for x86 SSE2 support.
__SSE2__ is the correct macro for SSE2 support with GCC, Clang,
and ICC. __SSE2_MATH__ means doing floating point math with SSE2
instead of 387. Often the latter macro is defined if the first
one is but it was still a bug.
2022-11-11 14:35:58 +02:00
Lasse Collin bd334ae56a Add NEWS for 5.2.7 (forgotten cherry-pick from v5.2). 2022-11-11 13:27:06 +02:00
Lasse Collin 3c7860cf49 xzdiff: Add support for .lz files.
The other scripts don't need changes for .lz support because
in those scripts it is enough that xz supports .lz.
2022-11-11 13:16:21 +02:00
Lasse Collin d76c752a6d Scripts: Ignore warnings from xz.
In practice this means making the scripts work when
the input files have an unsupported check type which
isn't a problem in practice unless support for
some check types has been disabled at build time.
2022-11-11 12:23:58 +02:00
Lasse Collin 6552535afd Translations: Rename poa4/fr_FR.po to po4a/fr.po.
That's how it is preferred at the Translation Project.
On my system /usr/share/man/fr_FR doesn't contain any
other man pages than XZ Utils while /usr/share/man/fr
has quite a few, so this will fix that too.

Thanks to Benno Schulenberg from the Translation Project.
2022-11-10 12:39:08 +02:00
Lasse Collin 0918159ce4 xz: Update the man page about BCJ filters, including upcoming --arm64.
The --arm64 isn't actually implemented yet in the form
described in this commit.

Thanks to Jia Tan.
2022-11-09 19:09:26 +02:00
Lasse Collin ba2ae3596f xz: Add --arm64 to --long-help and omit endianness from ARM(-Thumb).
Modern 32-bit ARM in big endian mode use little endian for
instruction encoding still, so the filters work on such
executables too. It's likely less confusing for users this way.

The --arm64 option hasn't been implemented yet (there is
--experimental-arm64 but it's different). The --arm64 option
is added now anyway because this is the likely result and the
strings need to be ready for translators.

Thanks to Jia Tan.
2022-11-09 18:14:14 +02:00
Lasse Collin 802d57d921 Windows: Update the VS project files for ARM64 and .lz support. 2022-11-09 15:12:13 +02:00
Lasse Collin 5846aeda05 DOS: Update Makefile and config.h to include ARM64 and .lz support. 2022-11-09 14:57:48 +02:00
Lasse Collin 781da8d6c4 CMake: Add lzip decoder files and #define to the build. 2022-11-09 14:45:05 +02:00
Lasse Collin df8ad4af65 Docs: Update INSTALL and also add new prohibited options to PACKAGERS. 2022-11-09 14:41:56 +02:00
Lasse Collin c8ef089c14 Tests: Test the .lz files in test_files.sh. 2022-11-09 14:32:33 +02:00
Lasse Collin c8f70ebb46 Tests: Add .lz (lzip) test files. 2022-11-09 14:31:21 +02:00
Lasse Collin 731db13e6f xz: Remove the commented-out FORMAT_GZIP, gzip, .gz, and .tgz. 2022-11-09 14:31:10 +02:00
Lasse Collin 3176f992c5 xz: Add .lz (lzip) decompression support.
If configured with --disable-lzip-decoder then --long-help will
still list `lzip' in --format but I left it like that since
due to translations it would be messy to have two help strings.
Features are disabled only in special situations so wrong help
in such a situation shouldn't matter much.

Thanks to Michał Górny for the original patch.
2022-11-09 14:28:41 +02:00
Lasse Collin 034086e1ae liblzma: Add .lz support to lzma_auto_decoder().
Thanks to Michał Górny for the original patch.
2022-11-09 14:25:26 +02:00
Lasse Collin 0538db038f liblzma: Add .lz (lzip) decompression support (format versions 0 and 1).
Support for format version 0 was removed from lzip 1.18 for some
reason. .lz format version 0 files are rare (and old) but some
source packages were released in this format, and some people might
have personal files in this format too. It's very little extra code
to support it along side format version 1 so this commits adds
support for both.

The Sync Flush marker extentension to the original .lz format
version 1 isn't supported. It would require changes to the
LZMA decoder itself. Such files are very rare anyway.

See the API doc for lzma_lzip_decoder() for more details about
the .lz format support.

Thanks to Michał Górny for the original patch.
2022-11-09 14:24:20 +02:00
Lasse Collin 633d48a075 liblzma: Add the missing Makefile.inc change for --disable-microlzma.
This was forgotten from commit 59c4d6e139.
2022-11-09 14:17:23 +02:00
Lasse Collin 724285dadb xz: Add comments about stdin and src_st.st_size.
"xz -v < regular_file > out.xz" doesn't display the percentage
and estimated remaining time because it doesn't even try to
check the input file size when input is read from stdin.
This could be improved but for now there's just a comment
to remind about it.
2022-11-09 14:10:52 +02:00
Lasse Collin f723eec68b xz: Fix displaying of file sizes in progress indicator in passthru mode.
It worked for one input file since the counters are zero when
xz starts but they weren't reset when starting a new file in
passthru mode. For example, if files A, B, and C are one byte each,
then "xz -dcvf A B C" would show file sizes as 1, 2, and 3 bytes
instead of 1, 1, and 1 byte.
2022-11-09 12:48:22 +02:00
Lasse Collin 69265d0f22 xz: Add a comment why --to-stdout is not in --help.
It is on the man page still.
2022-11-09 11:27:20 +02:00
Lasse Collin fe6b8852a3 xz: Make xz -lvv show that the upcoming --arm64 needs 5.4.0 to decompress. 2022-11-08 23:05:37 +02:00
Lasse Collin fb3f05ac9f Docs: Update faq.txt a little. 2022-11-08 22:26:54 +02:00
Lasse Collin 05331f091e Translations: Update Turkish translation. 2022-11-08 16:59:12 +02:00
Lasse Collin ed3a482296 Translations: Update Croatian translation. 2022-11-08 16:59:12 +02:00
Lasse Collin 4746f5ec72 liblzma: Update API docs about decoder flags. 2022-11-08 14:13:03 +02:00
Lasse Collin 8779a9db5d liblzma: Use the return_if_error() macro in alone_decoder.c. 2022-11-08 14:01:50 +02:00
Lasse Collin 3f4990b682 liblzma: Fix a comment in auto_decoder.c. 2022-11-08 14:00:58 +02:00
Lasse Collin 026a5897c7 xz: Initialize the pledge(2) sandbox at the very beginning of main().
It feels better that the initializations are sandboxed too.
They don't do anything that the pledge() call wouldn't allow.
2022-11-08 13:43:19 +02:00
Lasse Collin 49a59f6ca0 xz: Extend --robot --info-memory output.
Now it includes everything that the human-readable --info-memory shows.
2022-11-07 22:51:16 +02:00
Lasse Collin 5e2450c75c liblzma: Include cached memory in reported memusage in threaded decoder.
This affects lzma_memusage() and lzma_memlimit_set() when used
with the threaded decompressor. Now all allocations are reported
by lzma_memusage() (so it's not misleading) and lzma_memlimit_set()
cannot lower the limit below that value.

The alternative would have been to allow lowering the limit if
doing so is possible by freeing the cached memory but since
the primary use case of lzma_memlimit_set() is to increase
memlimit after LZMA_MEMLIMIT_ERROR this simple approach
was selected.

The cached memory was always included when enforcing
the memory usage limit while decoding.

Thanks to Jia Tan.
2022-11-07 17:22:04 +02:00
Jia Tan 1fc6e7dd1f xz: Avoid a compiler warning in progress_speed() in message.c.
This should be smaller too since it avoids the string constants.
2022-11-07 16:24:56 +02:00
Lasse Collin cf118c0146 Build: Clarify comment in configure.ac about SSE2. 2022-10-31 16:26:05 +02:00
Lasse Collin aad3c609ff Build: Remove obsolete commented-out lines from configure.ac. 2022-10-31 16:16:37 +02:00
Lasse Collin e53e0e2186 Windows: Fix mythread_once() macro with Vista threads.
Don't call InitOnceComplete() if initialization was already done.

So far mythread_once() has been needed only when building
with --enable-small. windows/build.bash does this together
with --disable-threads so the Vista-specific mythread_once()
is never needed by those builds. VS project files or
CMake-builds don't support HAVE_SMALL builds at all.
2022-10-31 13:31:58 +02:00
Lasse Collin 48dde3bab9 liblzma: Silence -Wconversion warning from crc64_fast.c. 2022-10-31 11:54:44 +02:00
Lasse Collin a243c617ff CMake: Sync tuklib_cpucores.cmake with tuklib_cpucores.m4.
This was forgotten from commit 2611c4d905.
2022-10-31 11:49:47 +02:00
Lasse Collin 05c72de06f Tests: test_files.sh: Make it not fail if features were disabled at build.
It now tries to test as many files as easily possible.
The exit status indicates skipping if any of the files were
skipped. This way it is easy to notice if something is being
skipped when it isn't expected.
2022-10-27 15:49:18 +03:00
Lasse Collin b3459327a5 Tests: test_files.sh: Suppress an expected warning from the log.
xz (but not xzdec) will normally warn about unsupported check
but since we are testing specifically such a file, it's better
to silence that warning so that it doesn't look suspicious in
test_files.sh.log.

The use of -q and -Q in xzdec is just for consistency and
doesn't affect the result at least for now.
2022-10-27 15:30:13 +03:00
Lasse Collin 798c86e423 Tests: test_files.sh: Print the reason for skipping if xz & xzdec missing. 2022-10-27 15:27:50 +03:00
Lasse Collin c1dd8524e1 Tests: Keep test_compress_* working when some filters are unavailable. 2022-10-27 01:12:40 +03:00
Jia Tan ce30ada919 Tests: test_bcj_exact_size skips properly now if PowerPC filter disabled. 2022-10-26 20:12:01 +03:00
Lasse Collin 89c5cfcaca Tests: Test also unsupported-*.xz. 2022-10-26 00:05:57 +03:00
Lasse Collin a4b214b93a Build: Use AC_CONFIG_HEADERS instead of the ancient AC_CONFIG_HEADER.
We require Autoconf >= 2.69 and that has AC_CONFIG_HEADERS.

There is a warning about AC_PROG_CC_C99 being obsolete but
it cannot be removed because it is needed with Autoconf 2.69.
2022-10-25 23:45:03 +03:00
Lasse Collin 04f299b64e Build: Update m4/ax_pthread.m4 from Autoconf Archive. 2022-10-25 23:31:44 +03:00
Lasse Collin 59c4d6e139 Build: Add configure option --disable-microlzma.
MicroLZMA was made for EROFS and used by erofs-utils.
It might be used by something else in the future but
those wanting a smaller build for specific situations
can now disable this rarely-needed feature.
2022-10-25 23:28:34 +03:00
Lasse Collin 054ccd6d14 xz: Fix --single-stream with an empty .xz Stream.
Example:

    $ xz -dc --single-stream good-0-empty.xz
    xz: good-0-empty.xz: Internal error (bug)

The code, that is tries to catch some input file issues early,
didn't anticipate LZMA_STREAM_END which is possible in that
code only when --single-stream is used.
2022-10-25 23:09:11 +03:00
Lasse Collin 563288ea70 xz: Add support for OpenBSD's pledge() sandbox. 2022-10-25 21:30:48 +03:00
Lasse Collin f9913e8ee2 xz: Fix decompressor behavior if input uses an unsupported check type.
Now files with unsupported check will make xz display
a warning, set the exit status to 2 (unless --no-warn is used),
and then decompress the file normally. This is how it was
supposed to work since the beginning but this was broken by
the commit 231c3c7098, that is,
a little before 5.0.0 was released. The buggy behavior displayed
a message, set exit status 1 (error), and xz didn't attempt to
to decompress the file.

This doesn't matter today except for special builds that disable
CRC64 or SHA-256 at build time (but such builds should be used
in special situations only). The bug matters if new check type
is added in the future and an old xz version is used to decompress
such a file; however, it's likely that such files would use a new
filter too and an old xz wouldn't be able to decompress the file
anyway.

The first hunk in the commit is the actual fix. The second hunk
is a cleanup since LZMA_TELL_ANY_CHECK isn't used in xz.

There is a test file for unsupported check type but it wasn't
used by test_files.sh, perhaps due to different behavior between
xz and the simpler xzdec.
2022-10-25 19:07:17 +03:00
Lasse Collin aa4fe145b9 xz: Clarify the man page: input file isn't removed if an error occurs. 2022-10-25 18:36:19 +03:00
Lasse Collin 8b46ae8cde xz: Refactor to remove is_empty_filename().
Long ago it was used in list.c too but nowadays it's needed
only in io_open_src() so it's nicer to avoid a separate function.
2022-10-25 18:30:55 +03:00
Lasse Collin 8562401597 xz: If input file cannot be removed, treat it as a warning, not error.
Treating it as a warning (message + exit status 2) matches gzip
and it seems more logical as at that point the output file has
already been successfully closed. When it's a warning it is
possible to suppress it with --no-warn.
2022-10-25 18:23:54 +03:00
Lasse Collin fda9f85f52 liblzma: Threaded decoder: Stop the worker threads on errors.
It's waste of CPU time and electricity to leave the unfinished
worker threads running when it is known that their output will
get ignored.
2022-10-24 16:25:09 +03:00
Lasse Collin 2611c4d905 tuklib_cpucores: Use HW_NCPUONLINE on OpenBSD.
On OpenBSD the number of cores online is often less
than what HW_NCPU would return because OpenBSD disables
simultaneous multi-threading (SMT) by default.

Thanks to Christian Weisgerber.
2022-10-20 20:22:50 +03:00
Lasse Collin 424ac91c7e Tests: Skip tests in test_*.sh if encoders and/or decoders are disabled.
This isn't perfect as the scripts can still fail if only
certain filters are disabled. This is still an improvement
as now "make check" has better behavior when all encoders
or decoders are disabled.

Grepping ../config.h is simple and fairly clean but it only
works if config.h was created. CMake builds don't create
config.h but they don't use these test scripts either.

Thanks to Sebastian Andrzej Siewior for reporting the problem.
Thanks to Jia Tan for the original patch which grepped xz
error messages instead of config.h.
2022-10-19 19:39:35 +03:00
Lasse Collin ca8bf9d7c5 Test: Remove the (exit 1) lines.
I suspect that I used these in the original version because
Autoconf's manual describes that such a trick is needed in
some specific situations for portability reasons. None of those
situations listed on Autoconf 2.71 manual apply to these test
scripts though so this cleans them up.
2022-10-19 19:03:50 +03:00
Lasse Collin 82fcb7cfc1 Tests: Fix a warning in test_memlimit.c when decoders are disabled. 2022-10-19 17:14:57 +03:00
Lasse Collin b5f8271b45 Tests: Add test_memlimit to .gitignore.
Thanks to Jia Tan.
2022-10-19 17:11:46 +03:00
Jia Tan 6a86e81cab Tests: Refactor test_stream_flags.c.
Converts test_stream_flags to tuktest. Also the test will now
compile and skip properly if encoders or decoders are disabled.

Thanks to Sebastian Andrzej Siewior.
2022-10-06 22:06:17 +03:00
Jia Tan 827ac5b482 Tests: Refactor test_block_header.c.
test_block_header now achieves higher test coverage. Also the
test will now compile and skip properly if encoders or decoders
are disabled.

Thanks to Sebastian Andrzej Siewior.
2022-10-06 21:51:48 +03:00
Jia Tan 8496331895 Tests: Fix compilation issues.
test_bcj_exact_size, test_check, test_hardware, and test_index will
all now compile and skip properly if encoders or decoders are disabled.

Also fixed a small typo (disabed -> disabled).

Thanks to Sebastian Andrzej Siewior.
2022-10-06 17:34:27 +03:00
Lasse Collin 7dcabeec63 Tests: Include mythread.h in the tests that use MYTHREAD_ENABLED. 2022-10-05 16:20:47 +03:00
Jia Tan 14af758a77 liblzma: Fix a compilation issue when encoders are disabled.
When encoders were disabled and threading enabled, outqueue.c and
outqueue.h were not compiled. The multi threaded decoder required
these files, so compilation failed.
2022-10-05 16:11:33 +03:00
Jia Tan 6ca5c354bd Tests: Fix compilation error when threading support has been disabled.
Now tests that require threading are skipped when threading
support has been disabled.

Thanks to Sebastian Andrzej Siewior.
2022-10-05 16:10:21 +03:00
Lasse Collin fae37ad2af tuklib_integer: Add 64-bit endianness-converting reads and writes.
Also update the comment in liblzma's memcmplen.h.

Thanks to Michał Górny for the original patch for the reads.
2022-10-05 14:26:00 +03:00
Lasse Collin 508a44372c liblzma: Add API doc note about the .xz decoder LZMA_MEMLIMIT_ERROR bug.
The bug was fixed in 660739f99a.
2022-09-30 12:06:13 +03:00
Jia Tan 8cc9874a79 liblzma: Add dest and src NULL checks to lzma_index_cat.
The documentation states LZMA_PROG_ERROR can be returned from
lzma_index_cat. Previously, lzma_index_cat could not return
LZMA_PROG_ERROR. Now, the validation is similar to
lzma_index_append, which does a NULL check on the index
parameter.
2022-09-28 15:48:03 +03:00
Jia Tan afd5a8bf53 Tests: Create a test for the lzma_index_cat bug. 2022-09-28 15:34:23 +03:00
Jia Tan 3d5a99ca37 liblzma: Fix copying of check type statistics in lzma_index_cat().
The check type of the last Stream in dest was never copied to
dest->checks (the code tried to copy it but it was done too late).
This meant that the value returned by lzma_index_checks() would
only include the check type of the last Stream when multiple
lzma_indexes had been concatenated.

In xz --list this meant that the summary would only list the
check type of the last Stream, so in this sense this was only
a visual bug. However, it's possible that some applications
use this information for purposes other than merely showing
it to the users in an informational message. I'm not aware of
such applications though and it's quite possible that such
applications don't exist.

Regular streamed decompression in xz or any other application
doesn't use lzma_index_cat() and so this bug cannot affect them.
2022-09-28 15:29:49 +03:00
Lasse Collin a61d321727 tuklib_physmem: Fix Unicode builds on Windows.
Thanks to ArSaCiA Game.
2022-09-28 12:20:41 +03:00
Lasse Collin 5a4d3548ab Tests: Add test_memlimit.c to test restarting after LZMA_MEMLIMIT_ERROR. 2022-09-28 11:12:07 +03:00
Lasse Collin 660739f99a liblzma: Stream decoder: Fix restarting after LZMA_MEMLIMIT_ERROR.
If lzma_code() returns LZMA_MEMLIMIT_ERROR it is now possible
to use lzma_memlimit_set() to increase the limit and continue
decoding. This was supposed to work from the beginning but
there was a bug. With other decoders (.lzma or threaded .xz)
this already worked correctly.
2022-09-28 11:05:15 +03:00
Lasse Collin 7e68fda58c liblzma: Stream decoder: Fix comments. 2022-09-28 11:00:23 +03:00
Lasse Collin f664cb2584 liblzma: ARM64: Add comments. 2022-09-20 16:58:22 +03:00
Lasse Collin b557b4a0ee liblzma: ARM64: Fix wrong comment in API doc.
Thanks to Jia Tan.
2022-09-20 16:27:50 +03:00
Lasse Collin d5b0906fa5 xz: Add --experimental-arm64[=width=WIDTH].
It will be renamed to --arm64 once it is stable.

Man page or --long-help weren't updated yet.
2022-09-19 20:24:26 +03:00
Lasse Collin ecb966de30 liblzma: Add experimental ARM64 BCJ filter with a temporary Filter ID.
That is, the Filter ID will be changed once the design is final.
The current version will be removed. So files created with the
tempoary Filter ID won't be supported in the future.
2022-09-19 20:23:46 +03:00
Lasse Collin 177bdc922c liblzma: Simple/BCJ filters: Allow disabling generic BCJ options.
This will be needed for the ARM64 BCJ filter as it will use
its own options struct.
2022-09-17 22:42:18 +03:00
Lasse Collin c3592d0a55 Tests: Add a test file for lzma_index_append() integer overflow bug.
This test fails before commit 18d7facd38.

test_files.sh now runs xz -l for bad-3-index-uncomp-overflow.xz
because only then the previously-buggy code path gets tested.
Normal decompression doesn't use lzma_index_append() at all.
Instead, lzma_index_hash functions are used and those already
did the overflow check.
2022-09-16 17:08:53 +03:00
Lasse Collin 982b29f828 Translations: Add Turkish translation. 2022-09-16 15:15:05 +03:00
Lasse Collin 1fc088d9f6 Update THANKS. 2022-09-16 14:09:07 +03:00
Lasse Collin 097c7b67ce xzgrep: Fix compatibility with old shells.
Running the current xzgrep on Slackware 10.1 with GNU bash 3.00.15:

    xzgrep: line 231: syntax error near unexpected token `;;'

On SCO OpenServer 5.0.7 with Korn Shell 93r:

    syntax error at line 231 : `;;' unexpected

Turns out that some old shells don't like apostrophes (') inside
command substitutions. For example, the following fails:

    x=$(echo foo
    # asdf'zxcv
    echo bar)
    printf '%s\n' "$x"

The problem was introduced by commits
69d1b3fc29 (2022-03-29),
bd7b290f3f (2022-07-18), and
a648978b20 (2022-07-19).
5.2.6 is the only stable release that included
this problem.

Thanks to Kevin R. Bulgrien for reporting the problem
on SCO OpenServer 5.0.7 and for providing the fix.
2022-09-16 14:07:03 +03:00
Lasse Collin f2d084fe3f Tests: Silence warnings about unused functions from tuktest.h.
Warnings about unused tuktest_run_test conveniently tell which
test programs haven't been converted to tuktest.h yet but I
silenced that warning too for now anyway.

It is fine to use __attribute__((__unused__)) even when the
function is actually used because the attribute only means
that the function might be unused.
2022-09-09 14:12:30 +03:00
Lasse Collin f8ee61e74e liblzma: lzma_filters_copy: Keep dest[] unmodified if an error occurs.
lzma_stream_encoder() and lzma_stream_encoder_mt() always assumed
this. Before this patch, failing lzma_filters_copy() could result
in free(invalid_pointer) or invalid memory reads in stream_encoder.c
or stream_encoder_mt.c.

To trigger this, allocating memory for a filter options structure
has to fail. These are tiny allocations so in practice they very
rarely fail.

Certain badness in the filter chain array could also make
lzma_filters_copy() fail but both stream_encoder.c and
stream_encoder_mt.c validate the filter chain before
trying to copy it, so the crash cannot occur this way.
2022-09-09 13:51:57 +03:00
Jia Tan 18d7facd38 liblzma: lzma_index_append: Add missing integer overflow check.
The documentation in src/liblzma/api/lzma/index.h suggests that
both the unpadded (compressed) size and the uncompressed size
are checked for overflow, but only the unpadded size was checked.
The uncompressed check is done first since that is more likely to
occur than the unpadded or index field size overflows.
2022-09-08 15:19:19 +03:00
Lasse Collin 9ac06cb5b8 Update THANKS. 2022-09-08 15:11:08 +03:00
Jia Tan ba3e4ba2de CMake: Clarify a comment about Windows symlinks without file extension. 2022-09-08 15:07:00 +03:00
Lasse Collin 17485e884c CMake: Update for liblzma_*.map files and fix wrong common_w32res.rc dep.
The previous commit split liblzma.map into liblzma_linux.map and
liblzma_generic.map. This commit updates the CMake build for those.

common_w32res.rc dependency was listed under Linux/FreeBSD while
obviously it belongs to Windows when building a DLL.
2022-09-08 15:02:41 +03:00
Lasse Collin 913ddc5572 liblzma: Vaccinate against an ill patch from RHEL/CentOS 7.
RHEL/CentOS 7 shipped with 5.1.2alpha, including the threaded
encoder that is behind #ifdef LZMA_UNSTABLE in the API headers.
In 5.1.2alpha these symbols are under XZ_5.1.2alpha in liblzma.map.
API/ABI compatibility tracking isn't done between development
releases so newer releases didn't have XZ_5.1.2alpha anymore.

Later RHEL/CentOS 7 updated xz to 5.2.2 but they wanted to keep
the exported symbols compatible with 5.1.2alpha. After checking
the ABI changes it turned out that >= 5.2.0 ABI is backward
compatible with the threaded encoder functions from 5.1.2alpha
(but not vice versa as fixes and extensions to these functions
were made between 5.1.2alpha and 5.2.0).

In RHEL/CentOS 7, XZ Utils 5.2.2 was patched with
xz-5.2.2-compat-libs.patch to modify liblzma.map:

  - XZ_5.1.2alpha was added with lzma_stream_encoder_mt and
    lzma_stream_encoder_mt_memusage. This matched XZ Utils 5.1.2alpha.

  - XZ_5.2 was replaced with XZ_5.2.2. It is clear that this was
    an error; the intention was to keep using XZ_5.2 (XZ_5.2.2
    has never been used in XZ Utils). So XZ_5.2.2 lists all
    symbols that were listed under XZ_5.2 before the patch.
    lzma_stream_encoder_mt and _mt_memusage are included too so
    they are listed both here and under XZ_5.1.2alpha.

The patch didn't add any __asm__(".symver ...") lines to the .c
files. Thus the resulting liblzma.so exports the threaded encoder
functions under XZ_5.1.2alpha only. Listing the two functions
also under XZ_5.2.2 in liblzma.map has no effect without
matching .symver lines.

The lack of XZ_5.2 in RHEL/CentOS 7 means that binaries linked
against unpatched XZ Utils 5.2.x won't run on RHEL/CentOS 7.
This is unfortunate but this alone isn't too bad as the problem
is contained within RHEL/CentOS 7 and doesn't affect users
of other distributions. It could also be fixed internally in
RHEL/CentOS 7.

The second problem is more serious: In XZ Utils 5.2.2 the API
headers don't have #ifdef LZMA_UNSTABLE for obvious reasons.
This is true in RHEL/CentOS 7 version too. Thus now programs
using new APIs can be compiled without an extra #define. However,
the programs end up depending on symbol version XZ_5.1.2alpha
(and possibly also XZ_5.2.2) instead of XZ_5.2 as they would
with an unpatched XZ Utils 5.2.2. This means that such binaries
won't run on other distributions shipping XZ Utils >= 5.2.0 as
they don't provide XZ_5.1.2alpha or XZ_5.2.2; they only provide
XZ_5.2 (and XZ_5.0). (This includes RHEL/CentOS 8 as the patch
luckily isn't included there anymore with XZ Utils 5.2.4.)

Binaries built by RHEL/CentOS 7 users get distributed and then
people wonder why they don't run on some other distribution.
Seems that people have found out about the patch and been copying
it to some build scripts, seemingly curing the symptoms but
actually spreading the illness further and outside RHEL/CentOS 7.

The ill patch seems to be from late 2016 (RHEL 7.3) and in 2017 it
had spread at least to EasyBuild. I heard about the events only
recently. :-(

This commit splits liblzma.map into two versions: one for
GNU/Linux and another for other OSes that can use symbol versioning
(FreeBSD, Solaris, maybe others). The Linux-specific file and the
matching additions to .c files add full compatibility with binaries
that have been built against a RHEL/CentOS-patched liblzma. Builds
for OSes other than GNU/Linux won't get the vaccine as they should
be immune to the problem (I really hope that no build script uses
the RHEL/CentOS 7 patch outside GNU/Linux).

The RHEL/CentOS compatibility symbols XZ_5.1.2alpha and XZ_5.2.2
are intentionally put *after* XZ_5.2 in liblzma_linux.map. This way
if one forgets to #define HAVE_SYMBOL_VERSIONS_LINUX when building,
the resulting liblzma.so.5 will have lzma_stream_encoder_mt@@XZ_5.2
since XZ_5.2 {...} is the first one that lists that function.
Without HAVE_SYMBOL_VERSIONS_LINUX @XZ_5.1.2alpha and @XZ_5.2.2
will be missing but that's still a minor problem compared to
only having lzma_stream_encoder_mt@@XZ_5.1.2alpha!

The "local: *;" line was moved to XZ_5.0 so that it doesn't need
to be moved around. It doesn't matter where it is put.

Having two similar liblzma_*.map files is a bit silly as it is,
at least for now, easily possible to generate the generic one
from the Linux-specific file. But that adds extra steps and
increases the risk of mistakes when supporting more than one
build system. So I rather maintain two files in parallel and let
validate_map.sh check that they are in sync when "make mydist"
is run.

This adds .symver lines for lzma_stream_encoder_mt@XZ_5.2.2 and
lzma_stream_encoder_mt_memusage@XZ_5.2.2 even though these
weren't exported by RHEL/CentOS 7 (only @@XZ_5.1.2alpha was
for these two). I added these anyway because someone might
misunderstand the RHEL/CentOS 7 patch and think that @XZ_5.2.2
(@@XZ_5.2.2) versions were exported too.

At glance one could suggest using __typeof__ to copy the function
prototypes when making aliases. However, this doesn't work trivially
because __typeof__ won't copy attributes (lzma_nothrow, lzma_pure)
and it won't change symbol visibility from hidden to default (done
by LZMA_API()). Attributes could be copied with __copy__ attribute
but that needs GCC 9 and a fallback method would be needed anyway.

This uses __symver__ attribute with GCC >= 10 and
__asm__(".symver ...") with everything else. The attribute method
is required for LTO (-flto) support with GCC. Using -flto with
GCC older than 10 is now broken on GNU/Linux and will not be fixed
(can silently result in a broken liblzma build that has dangerously
incorrect symbol versions). LTO builds with Clang seem to work
with the traditional __asm__(".symver ...") method.

Thanks to Boud Roukema for reporting the problem and discussing
the details and testing the fix.
2022-09-08 15:01:29 +03:00
Lasse Collin 80a1a8bb83 CMake: Add xz symlinks.
These are a minor thing especially since the xz build has
some real problems still like lack of large file support
on 32-bit systems but I'll commit this since the code exists.

Thanks to Jia Tan.
2022-08-31 16:42:04 +03:00
Lasse Collin a4193bb6d8 CMake: Put xz man page install under if(UNIX) like is for xzdec.
Thanks to Jia Tan.
2022-08-31 16:29:38 +03:00
Lasse Collin c1555b1a22 Bump version number for 5.3.3alpha. 2022-08-22 18:16:40 +03:00
Lasse Collin 44fedddc11 Add NEWS for 5.3.3alpha. 2022-08-22 18:13:56 +03:00
Lasse Collin a93e235d7c Translations: Add Portuguese translation.
Jia Tan made white-space changes and also changed "Language: pt_BR\n"
to pt. The translator wasn't reached so I'm hoping these changes
are OK and will commit it without translator's approval.

Thanks to Pedro Albuquerque and Jia Tan.
2022-08-22 18:06:38 +03:00
Lasse Collin e7cf5a946f Translations: Add Serbian translation.
Quite a few white-space changes were made by Jia Tan to make
this look good. Contacting the translator didn't succeed so
I'm committing this without getting translator's approval.

Thanks to Мирослав Николић (Miroslav Nikolic) and Jia Tan.
2022-08-22 18:06:37 +03:00
Lasse Collin cc8617ab53 Translations: Add Swedish translation.
Thanks to Sebastian Rasmussen and Jia Tan.
2022-08-22 18:06:37 +03:00
Lasse Collin c613598c35 Translations: Add Esperanto translation.
Thanks to Keith Bowes and Jia Tan.
2022-08-22 18:06:37 +03:00
Lasse Collin 659a587d67 Translations: Add Catalan translation.
Thanks to Jordi Mas and Jia Tan.
2022-08-22 18:06:37 +03:00
Lasse Collin 739fd8c9bd Translations: Add Ukrainian translation.
Thanks to Yuri Chornoivan and Jia Tan.
2022-08-22 18:06:37 +03:00
Lasse Collin 73280550b1 Translators: Add Romanian translation.
Thanks to Remus-Gabriel Chelu and Jia Tan.
2022-08-22 18:06:37 +03:00
Lasse Collin 2465f5b825 Translations: Update Brazilian Portuguese translation.
One msgstr was changed. The diff is long due to changes
in the source code line numbers in the comments.

Thanks to Rafael Fontenelle.
2022-08-22 18:06:37 +03:00
Lasse Collin 434e1ffd3e Translations: Add Croatian translation.
Thanks to Božidar Putanec and Jia Tan.
2022-08-22 18:06:37 +03:00
Lasse Collin 0732d0f706 Translations: Add Spanish translation.
Thanks to Cristian Othón Martínez Vera and Jia Tan.
2022-08-22 18:06:37 +03:00
Lasse Collin 9899b0f82b Translations: Add Korean translation.
Thanks to Seong-ho Cho and Jia Tan.
2022-08-22 18:06:37 +03:00
Lasse Collin 65217eaf6b Translations: Rebuild cs.po to avoid incorrect fuzzy strings.
"make dist" updates the .po files and the fuzzy strings would
result in multiple very wrong translations.
2022-08-22 18:06:37 +03:00
Lasse Collin e56ff423ee Translations: Add partial Danish translation.
I made a few minor white space changes without getting them
approved by the Danish translation team.
2022-08-22 18:06:37 +03:00
Lasse Collin 43e09c62e7 Translations: Add hu, zh_CN, and zh_TW.
I made a few white space changes to these without getting them
approved by the translation teams. (I tried to contact the hu and
zh_TW teams but didn't succeed. I didn't contact the zh_CN team.)
2022-08-22 18:06:37 +03:00
Lasse Collin 982b6b198a Translations: Update vi.po to match the file from the TP.
The translated strings haven't been updated but word wrapping
is different.
2022-08-22 18:06:37 +03:00
Lasse Collin 801f39691f Translations: Add fi and pt_BR, and update de, fr, it, and pl.
The German translation isn't identical to the file in
the Translation Project but the changes (white space changes
only) were approved by the translator Mario Blättermann.
2022-08-22 18:06:37 +03:00
Lasse Collin 311e4f85ed xz: Try to clarify --memlimit-mt-decompress vs. --memlimit-compress. 2022-08-22 18:01:21 +03:00
Lasse Collin df23c31000 CMake: Add liblzma tests.
Thanks to Jia Tan for the patch.
2022-08-22 16:46:18 +03:00
Lasse Collin 02a777f9c4 xz: Revise --info-memory output.
The strings could be more descriptive but it's good
to have some version of this committed now.

--robot mode wasn't changed yet.
2022-08-19 23:40:00 +03:00
Lasse Collin f864f6d42e xz: Update the man page for threaded decompression and memlimits.
This documents the changes made in commits
6c6da57ae2,
cad299008c, and
898faa9728.

The --info-memory bit hasn't been finished yet
even though it's already mentioned in this commit
under --memlimit-mt-decompress and --threads.
2022-08-19 23:15:56 +03:00
Lasse Collin d13bfcc005 Build: Include the CMake files in the distribution.
This was supposed to be done in 2020 with 5.2.5 release
already but it was noticed only today. 5.2.5 and 5.2.6
even mention experiemental CMake support in the NEWS entries.

Thanks to Olivier B. for reporting the problem.
2022-08-18 17:49:16 +03:00
Lasse Collin e66787bcfe Windows: Fix broken liblzma.dll build with Visual Studio project files.
The bug was introduced in 352ba2d69a
"Windows: Fix building of resource files when config.h isn't used."

That commit fixed liblzma.dll build with CMake while keeping it
working with Autotools on Windows but the VS project files were
forgotten.

I haven't tested these changes.

Thanks to Olivier B. for reporting the bug and for the initial patch.
2022-08-18 17:38:05 +03:00
Lasse Collin c4e8e5fb31 liblzma: Threaded decoder: Improve LZMA_FAIL_FAST when LZMA_FINISH is used.
It will now return LZMA_DATA_ERROR (not LZMA_OK or LZMA_BUF_ERROR)
if LZMA_FINISH is used and there isn't enough input to finish
decoding the Block Header or the Block. The use of LZMA_DATA_ERROR
is simpler and the less risky than LZMA_BUF_ERROR but this might
be changed before 5.4.0.
2022-08-18 17:16:49 +03:00
Lasse Collin 6dcf606e7e Add NEWS for 5.2.6. 2022-08-12 18:31:47 +03:00
Lasse Collin 413b86fcf8 Add Jia Tan to AUTHORS. 2022-08-12 14:28:41 +03:00
Lasse Collin 352672732c Build: Start the generated ChangeLog from around 5.2.0 instead of 5.0.0.
This makes ChangeLog smaller.
2022-07-25 19:28:26 +03:00
Lasse Collin 6f6d11225d Translations: Change the copyright comment string to use with po4a.
This affects the second line in po4a/xz-man.pot. The man pages of
xzdiff, xzgrep, and xzmore are from GNU gzip and under GNU GPLv2+
while the rest of the man pages are in the public domain.
2022-07-25 19:11:05 +03:00
Jia Tan 61f8ec804a liblzma: Refactor lzma_mf_is_supported() to use a switch-statement. 2022-07-25 18:30:10 +03:00
Jia Tan 4d80b463a1 Build: Don't allow empty LIST in --enable-match-finders=LIST.
It's enforced only when a match finder is needed, that is,
when LZMA1 or LZMA2 encoder is enabled.
2022-07-25 18:20:01 +03:00
Lasse Collin 9cc721af54 xz: Update the man page that change to --keep will be in 5.2.6. 2022-07-24 13:27:48 +03:00
Lasse Collin b81bf0c7d1 Update THANKS. 2022-07-19 23:23:54 +03:00
Nicholas Jackson 340cf1ec39 CMake: Add missing source file to liblzma build 2022-07-19 23:21:44 +03:00
Lasse Collin d796b6d7fd xzgrep man page: Document exit statuses. 2022-07-19 23:19:49 +03:00
Lasse Collin 923bf96b55 xzgrep: Improve error handling, especially signals.
xzgrep wouldn't exit on SIGPIPE or SIGQUIT when it clearly
should have. It's quite possible that it's not perfect still
but at least it's much better.

If multiple exit statuses compete, now it tries to pick
the largest of value.

Some comments were added.

The exit status handling of signals is still broken if the shell
uses values larger than 255 in $? to indicate that a process
died due to a signal ***and*** their "exit" command doesn't take
this into account. This seems to work well with the ksh and yash
versions I tried. However, there is a report in gzip/zgrep that
OpenSolaris 5.11 (not 5.10) has a problem with "exit" truncating
the argument to 8 bits:

    https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22900#25

Such a bug would break xzgrep but I didn't add a workaround
at least for now. 5.11 is old and I don't know if the problem
exists in modern descendants, or if the problem exists in other
ksh implementations in use.
2022-07-19 23:13:24 +03:00
Lasse Collin a648978b20 xzgrep: Make the fix for ZDI-CAN-16587 more robust.
I don't know if this can make a difference in the real world
but it looked kind of suspicious (what happens with sed
implementations that cannot process very long lines?).
At least this commit shouldn't make it worse.
2022-07-19 00:10:55 +03:00
Lasse Collin bd7b290f3f xzgrep: Use grep -H --label when available (GNU, *BSDs).
It avoids the use of sed for prefixing filenames to output lines.
Using sed for that is slower and prone to security bugs so now
the sed method is only used as a fallback.

This also fixes an actual bug: When grepping a binary file,
GNU grep nowadays prints its diagnostics to stderr instead of
stdout and thus the sed-method for prefixing the filename doesn't
work. So with this commit grepping binary files gives reasonable
output with GNU grep now.

This was inspired by zgrep but the implementation is different.
2022-07-18 22:06:10 +03:00
Lasse Collin b56729af9f xzgrep: Use -e to specify the pattern to grep.
Now we don't need the separate test for adding the -q option
as it can be added directly in the two places where it's needed.
2022-07-18 21:10:25 +03:00
Lasse Collin bad61b5997 Scripts: Use printf instead of echo in a few places.
It's a good habbit as echo has some portability corner cases
when the string contents can be anything.
2022-07-18 19:18:48 +03:00
Lasse Collin 6a4a4a7d26 xzgrep: Add more LC_ALL=C to avoid bugs with multibyte characters.
Also replace one use of expr with printf.

The rationale for LC_ALL=C was already mentioned in
69d1b3fc29 that fixed a security
issue. However, unrelated uses weren't changed in that commit yet.

POSIX says that with sed and such tools one should use LC_ALL=C
to ensure predictable behavior when strings contain byte sequences
that aren't valid multibyte characters in the current locale. See
under "Application usage" in here:

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html

With GNU sed invalid multibyte strings would work without this;
it's documented in its Texinfo manual. Some other implementations
aren't so forgiving.
2022-07-17 21:36:25 +03:00
Lasse Collin b48f9d615f xzgrep: Fix parsing of certain options.
Fix handling of "xzgrep -25 foo" (in GNU grep "grep -25 foo" is
an alias for "grep -C25 foo"). xzgrep would treat "foo" as filename
instead of as a pattern. This bug was fixed in zgrep in gzip in 2012.

Add -E, -F, -G, and -P to the "no argument required" list.

Add -X to "argument required" list. It is an
intentionally-undocumented GNU grep option so this isn't
an important option for xzgrep but it seems that other grep
implementations (well, those that I checked) don't support -X
so I hope this change is an improvement still.

grep -d (grep --directories=ACTION) requires an argument. In
contrast to zgrep, I kept -d in the "no argument required" list
because it's not supported in xzgrep (or zgrep). This way
"xzgrep -d" gives an error about option being unsupported instead
of telling that it requires an argument. Both zgrep and xzgrep
tell that it's unsupported if an argument is specified.

Add comments.
2022-07-17 20:57:06 +03:00
Lasse Collin 2d2201bc63 Tests: Add the .lzma files to test_files.sh. 2022-07-14 20:33:05 +03:00
Lasse Collin ce5549a591 Tests: Add .lzma test files. 2022-07-14 19:37:42 +03:00
Lasse Collin 107c93ee5c liblzma: Rename a variable and improve a comment. 2022-07-14 18:12:38 +03:00
Lasse Collin 511feb5ead Update THANKS. 2022-07-13 22:24:41 +03:00
Lasse Collin 9595a3119b liblzma: Add optional autodetection of LZMA end marker.
Turns out that this is needed for .lzma files as the spec in
LZMA SDK says that end marker may be present even if the size
is stored in the header. Such files are rare but exist in the
real world. The code in liblzma is so old that the spec didn't
exist in LZMA SDK back then and I had understood that such
files weren't possible (the lzma tool in LZMA SDK didn't
create such files).

This modifies the internal API so that LZMA decoder can be told
if EOPM is allowed even when the uncompressed size is known.
It's allowed with .lzma and not with other uses.

Thanks to Karl Beldan for reporting the problem.
2022-07-13 22:24:07 +03:00
Lasse Collin 0c0f8e9761 xz: Document the special memlimit case of 2000 MiB on MIPS32.
See commit fc3d3a7296.
2022-07-12 18:53:04 +03:00
Jia Tan d1bfa3dc70 Created script to generate code coverage reports.
The script uses lcov and genhtml after running the tests
to show the code coverage statistics. The script will create
a coverage directory where it is run. It can be run both in
and out of the source directory.
2022-07-10 22:42:22 +03:00
Jia Tan 86a30b0255 Tests: Add more tests into test_check. 2022-06-16 17:39:59 +03:00
Lasse Collin 82e30fed66 Tests: Use char[][24] array for enum_strings_lzma_ret.
Array of pointers to short strings is a bit pointless here
and now it's fully const.
2022-06-16 15:02:57 +03:00
Lasse Collin 5ba9459e6c Tests: tuktest.h: Add tuktest_error_impl to help with error conditions. 2022-06-16 14:12:14 +03:00
Lasse Collin b339892668 Tests: tuktest.h: Rename file_from_* and use tuktest_malloc there. 2022-06-16 13:29:59 +03:00
Lasse Collin d8b63a0ad6 Tests: tuktest.h: Add malloc wrapper with automatic freeing. 2022-06-16 13:08:19 +03:00
Lasse Collin 1d51536a4b Tests: tuktest.h: Move a function. 2022-06-16 11:47:37 +03:00
Lasse Collin 70c7555f64 Tests: test_vli: Remove an invalid test-assertion.
lzma_vli is unsigned so trying a signed value results in
a compiler warning from -Wsign-conversion. (lzma_vli)-1
equals to LZMA_VLI_UNKNOWN anyway which is the next assertion.
2022-06-14 22:21:15 +03:00
Lasse Collin 154b73c5a1 Tests: test_vli: Add const where appropriate. 2022-06-14 22:17:01 +03:00
Jia Tan 0354d6cce3 Added vli tests to .gitignore 2022-06-14 22:03:55 +03:00
Jia Tan a08f5ccf6b Created tests for all functions exported in vli.h
Achieved 100% code coverage vli_encoder.c, vli_decoder.c, and vli_size.c
2022-06-14 22:00:34 +03:00
jiat75 1e3eb61815 Added parallel test artifacts to .gitignore 2022-06-14 21:47:09 +03:00
Lasse Collin 00e3613f12 Tests: Use good-1-empty-bcj-lzma2.xz in test_bcj_exact_size.
It's much nicer this way so that the test data isn't a hardcoded
table inside the C file.
2022-06-14 21:29:21 +03:00
Lasse Collin 86bab755be Tests: Add file reading helpers to tuktest.h. 2022-06-14 21:26:13 +03:00
Lasse Collin 83d2337b72 Tests: tuktest.h: Move a printf from a macro to a helper function. 2022-06-14 18:21:57 +03:00
Lasse Collin f9e8176ea7 Tests: Add test file good-1-empty-bcj-lzma2.xz.
This is from test_bcj_exact_size.c.
It's good to have it as a standalone file.
2022-06-14 17:20:49 +03:00
Jia Tan aa75c5563a Tests: Created tests for hardware functions.
Created tests for all API functions exported in
src/liblzma/api/lzma/hardware.h. The tests are fairly trivial
but are helpful because they will inform users if their machines
cannot support these functions. They also improve the code
coverage metrics.
2022-06-10 16:58:47 +03:00
Lasse Collin 5c8ffdca20 Tests: Convert test_check to tuktest.
Thanks to Jia Tan for help with all the tests.
2022-06-02 21:06:58 +03:00
Lasse Collin faf5ff8899 Tests: Convert test_block_header to tuktest. 2022-06-02 20:45:05 +03:00
Lasse Collin 754d39fbeb Tests: Convert test_bcj_exact_size to tuktest.
The compress() and decompress() functions were merged because
the later depends on the former so they need to be a single
test case.
2022-06-02 20:28:23 +03:00
Lasse Collin 96da21470f Tests: Include tuktest.h in tests.h.
This breaks -Werror because none of the tests so far use
tuktest.h and thus there are warnings about unused variables
and functions.
2022-06-02 20:27:00 +03:00
Lasse Collin df71ba1c99 Tests: Add tuktest.h mini-test-framework. 2022-06-02 20:25:21 +03:00
Lasse Collin 4773608554 Build: Enable Automake's parallel test harness.
It has been the default for quite some time already and
the old serial harness isn't discouraged. The downside is
that with parallel tests one cannot print progress info or
other diagnostics to the terminal; all output from the tests
will be in the log files only. But now that the compression
tests are separated the parallel tests will speed things up.
2022-05-23 21:31:36 +03:00
Lasse Collin 9a6dd6d46f Tests: Split test_compress.sh into separate test unit for each file.
test_compress.sh now takes one command line argument:
a filename to be tested. If it begins with "compress_generated_"
the file will be created with create_compress_files.

This will allow parallel execution of the slow tests.
2022-05-23 21:31:20 +03:00
Lasse Collin c7758ac9c7 Test: Make create_compress_files.c a little more flexible.
If a command line argument is given, then only the test file
of that type is created. It's quite dumb in sense that unknown
names don't give an error but it's good enough here.

Also use EXIT_FAILURE instead of 1 as exit status for errors.
2022-05-23 20:59:47 +03:00
Lasse Collin 4a8e4a7b0a Tests: Remove unneeded commented lines from test_compress.sh. 2022-05-23 20:17:42 +03:00
Lasse Collin 2ee50d150e Tests: Remove progress indicator from test_compress.sh.
It will be useless with Automake's parallel tests.
2022-05-23 20:16:00 +03:00
Lasse Collin 2ce4f36f17 liblzma: Silence a warning.
The actual initialization is done via mythread_sync and seems
that GCC doesn't necessarily see that it gets initialized there.
2022-05-23 19:37:18 +03:00
Lasse Collin 5d8f3764ef xz: Fix build with --disable-threads. 2022-04-14 20:53:16 +03:00
Lasse Collin 1d59289727 xz: Change the cap of the default -T0 memlimit for 32-bit xz.
The SIZE_MAX / 3 was 1365 MiB. 1400 MiB gives little more room
and it looks like a round (artificial) number in --info-memory
once --info-memory is made to display it.

Also, using #if avoids useless code on 64-bit builds.
2022-04-14 14:50:17 +03:00
Lasse Collin c77fe55ddb xz: Add a default soft memory usage limit for --threads=0.
This is a soft limit in sense that it only affects the number of
threads. It never makes xz fail and it never makes xz change
settings that would affect the compressed output.

The idea is to make -T0 have more reasonable behavior when
the system has very many cores or when a memory-hungry
compression options are used. This also helps with 32-bit xz,
preventing it from running out of address space.

The downside of this commit is that now the number of threads
might become too low compared to what the user expected. I
hope this to be an acceptable compromise as the old behavior
has been a source of well-argued complaints for a long time.
2022-04-14 14:20:46 +03:00
Lasse Collin 0adc13bfe3 xz: Make -T0 use multithreaded mode on single-core systems.
The main problem withi the old behavior is that the compressed
output is different on single-core systems vs. multicore systems.
This commit fixes it by making -T0 one thread in multithreaded mode
on single-core systems.

The downside of this is that it uses more memory. However, if
--memlimit-compress is used, xz can (thanks to the previous commit)
drop to the single-threaded mode still.
2022-04-14 13:00:40 +03:00
Lasse Collin 898faa9728 xz: Changes to --memlimit-compress and --no-adjust.
In single-threaded mode, --memlimit-compress can make xz scale down
the LZMA2 dictionary size to meet the memory usage limit. This
obviously affects the compressed output. However, if xz was in
threaded mode, --memlimit-compress could make xz reduce the number
of threads but it wouldn't make xz switch from multithreaded mode
to single-threaded mode or scale down the LZMA2 dictionary size.
This seemed illogical and there was even a "FIXME?" about it.

Now --memlimit-compress can make xz switch to single-threaded
mode if one thread in multithreaded mode uses too much memory.
If memory usage is still too high, then the LZMA2 dictionary
size can be scaled down too.

The option --no-adjust was also changed so that it no longer
prevents xz from scaling down the number of threads as that
doesn't affect compressed output (only performance). After
this commit --no-adjust only prevents adjustments that affect
compressed output, that is, with --no-adjust xz won't switch
from multithreaded mode to single-threaded mode and won't
scale down the LZMA2 dictionary size.

The man page wasn't updated yet.
2022-04-14 12:38:00 +03:00
Lasse Collin cad299008c xz: Add --memlimit-mt-decompress along with a default limit value.
--memlimit-mt-decompress allows specifying the limit for
multithreaded decompression. This matches memlimit_threading in
liblzma. This limit can only affect the number of threads being
used; it will never prevent xz from decompressing a file. The
old --memlimit-decompress option is still used at the same time.

If the value of --memlimit-decompress (the default value or
one specified by the user) is less than the value of
--memlimit-mt-decompress , then --memlimit-mt-decompress is
reduced to match --memlimit-decompress.

Man page wasn't updated yet.
2022-04-12 00:04:30 +03:00
Lasse Collin fe87b4cd53 liblzma: Threaded decoder: Improve setting of pending_error.
It doesn't need to be done conditionally. The comments try
to explain it.
2022-04-06 23:11:59 +03:00
Lasse Collin 90621da7f6 liblzma: Add a new flag LZMA_FAIL_FAST for threaded decoder.
In most cases if the input file is corrupt the application won't
care about the uncompressed content at all. With this new flag
the threaded decoder will return an error as soon as any thread
has detected an error; it won't wait to copy out the data before
the location of the error.

I don't plan to use this in xz to keep the behavior consistent
between single-threaded and multi-threaded modes.
2022-04-06 13:16:00 +03:00
Lasse Collin 64b6d496dc liblzma: Threaded decoder: Always wait for output if LZMA_FINISH is used.
This makes the behavior consistent with the single-threaded
decoder when handling truncated .xz files.

Thanks to Jia Tan for finding this issue.
2022-04-05 12:24:57 +03:00
Lasse Collin e671bc8828 liblzma: Threaded decoder: Support zpipe.c-style decoding loop.
This makes it possible to call lzma_code() in a loop that only
reads new input when lzma_code() didn't fill the output buffer
completely. That isn't the calling style suggested by the
liblzma example program 02_decompress.c so perhaps the usefulness
of this feature is limited.

Also, it is possible to write such a loop so that it works
with the single-threaded decoder but not with the threaded
decoder even after this commit, or so that it works only if
lzma_mt.timeout = 0.

The zlib tutorial <https://zlib.net/zlib_how.html> is a well-known
example of a loop where more input is read only when output isn't
full. Porting this as is to liblzma would work with the
single-threaded decoder (if LZMA_CONCATENATED isn't used) but it
wouldn't work with threaded decoder even after this commit because
the loop assumes that no more output is possible when it cannot
read more input ("if (strm.avail_in == 0) break;"). This cannot
be fixed at liblzma side; the loop has to be modified at least
a little.

I'm adding this in any case because the actual code is simple
and short and should have no harmful side-effects in other
situations.
2022-04-02 21:49:59 +03:00
Lasse Collin 2ba8173e27 Update THANKS. 2022-03-31 00:05:07 +03:00
Lasse Collin 69d1b3fc29 xzgrep: Fix escaping of malicious filenames (ZDI-CAN-16587).
Malicious filenames can make xzgrep to write to arbitrary files
or (with a GNU sed extension) lead to arbitrary code execution.

xzgrep from XZ Utils versions up to and including 5.2.5 are
affected. 5.3.1alpha and 5.3.2alpha are affected as well.
This patch works for all of them.

This bug was inherited from gzip's zgrep. gzip 1.12 includes
a fix for zgrep.

The issue with the old sed script is that with multiple newlines,
the N-command will read the second line of input, then the
s-commands will be skipped because it's not the end of the
file yet, then a new sed cycle starts and the pattern space
is printed and emptied. So only the last line or two get escaped.

One way to fix this would be to read all lines into the pattern
space first. However, the included fix is even simpler: All lines
except the last line get a backslash appended at the end. To ensure
that shell command substitution doesn't eat a possible trailing
newline, a colon is appended to the filename before escaping.
The colon is later used to separate the filename from the grep
output so it is fine to add it here instead of a few lines later.

The old code also wasn't POSIX compliant as it used \n in the
replacement section of the s-command. Using \<newline> is the
POSIX compatible method.

LC_ALL=C was added to the two critical sed commands. POSIX sed
manual recommends it when using sed to manipulate pathnames
because in other locales invalid multibyte sequences might
cause issues with some sed implementations. In case of GNU sed,
these particular sed scripts wouldn't have such problems but some
other scripts could have, see:

    info '(sed)Locale Considerations'

This vulnerability was discovered by:
cleemy desu wayo working with Trend Micro Zero Day Initiative

Thanks to Jim Meyering and Paul Eggert discussing the different
ways to fix this and for coordinating the patch release schedule
with gzip.
2022-03-29 20:10:50 +03:00
Lasse Collin bd93b776c1 liblzma: Fix a deadlock in threaded decoder.
If a worker thread has consumed all input so far and it's
waiting on thr->cond and then the main thread enables
partial update for that thread, the code used to deadlock.
This commit allows one dummy decoding pass to occur in this
situation which then also does the partial update.

As part of the fix, this moves thr->progress_* updates to
avoid the second thr->mutex locking.

Thanks to Jia Tan for finding, debugging, and reporting the bug.
2022-03-26 01:15:32 +02:00
Lasse Collin e0394e9423 Update THANKS. 2022-03-23 16:34:00 +02:00
Lasse Collin 487c77d487 liblzma: Threaded decoder: Don't stop threads on LZMA_TIMED_OUT.
LZMA_TIMED_OUT is not an error and thus stopping threads on
LZMA_TIMED_OUT breaks the decoder badly.

Thanks to Jia Tan for finding the bug and for the patch.
2022-03-23 16:28:55 +02:00
Lasse Collin 6c6da57ae2 xz: Add initial support for threaded decompression.
If threading support is enabled at build time, this will
use lzma_stream_decoder_mt() even for single-threaded mode.
With memlimit_threading=0 the behavior should be identical.

This needs some work like adding --memlimit-threading=LIMIT.

The original patch from Sebastian Andrzej Siewior included
a method to get currently available RAM on Linux. It might
be one way to go but as it is Linux-only, the available-RAM
approach needs work for portability or using a fallback method
on other OSes.

The man page wasn't updated yet.
2022-03-07 00:36:16 +02:00
Lasse Collin 4cce3e27f5 liblzma: Add threaded .xz decompressor.
I realize that this is about a decade late.

Big thanks to Sebastian Andrzej Siewior for the original patch.
I made a bunch of smaller changes but after a while quite a few
things got rewritten. So any bugs in the commit were created by me.
2022-03-07 00:35:53 +02:00
Lasse Collin 717631b978 liblzma: Fix docs: lzma_block_decoder() cannot return LZMA_UNSUPPORTED_CHECK.
If Check is unsupported, it will be silently ignored.
It's the caller's job to handle it.
2022-03-06 16:54:23 +02:00
Lasse Collin 1a4bb97a00 liblzma: Add new output queue (lzma_outq) features.
Add lzma_outq_clear_cache2() which may leave one buffer allocated
in the cache.

Add lzma_outq_outbuf_memusage() to get the memory needed for
a single lzma_outbuf. This is now used internally in outqueue.c too.

Track both the total amount of memory allocated and the amount of
memory that is in active use (not in cache).

In lzma_outbuf, allow storing the current input position that
matches the current output position. This way the main thread
can notice when no more output is possible without first providing
more input.

Allow specifying return code for lzma_outq_read() in a finished
lzma_outbuf.
2022-03-06 16:41:19 +02:00
Lasse Collin ddbc6f58c2 liblzma: Index hash: Change return value type of hash_append() to void. 2022-03-06 15:18:58 +02:00
Lasse Collin 20e7a33e2d liblzma: Minor addition to lzma_vli_size() API doc.
Thanks to Jia Tan.
2022-02-22 03:42:57 +02:00
Lasse Collin 4f78f5fcf6 liblzma: Check the return value of lzma_index_append() in threaded encoder.
If lzma_index_append() failed (most likely memory allocation failure)
it could have gone unnoticed and the resulting .xz file would have
an incorrect Index. Decompressing such a file would produce the
correct uncompressed data but then an error would occur when
verifying the Index field.
2022-02-22 02:04:18 +02:00
Lasse Collin 5313ad66b4 Update THANKS. 2022-02-22 01:37:39 +02:00
Ed Maste 865e0a3689 liblzma: Use non-executable stack on FreeBSD as on Linux 2022-02-22 01:23:34 +02:00
Lasse Collin 1c9a5786d2 liblzma: Make Block decoder catch certain types of errors better.
Now it limits the input and output buffer sizes that are
passed to a raw decoder. This way there's no need to check
if the sizes can grow too big or overflow when updating
Compressed Size and Uncompressed Size counts. This also means
that a corrupt file cannot cause the raw decoder to process
useless extra input or output that would exceed the size info
in Block Header (and thus cause LZMA_DATA_ERROR anyway).

More importantly, now the size information is verified more
carefully in case raw decoder returns LZMA_OK. This doesn't
really matter with the current single-threaded .xz decoder
as the errors would be detected slightly later anyway. But
this helps avoiding corner cases in the upcoming threaded
decompressor, and it might help other Block decoder uses
outside liblzma too.

The test files bad-1-lzma2-{9,10,11}.xz test these conditions.
With the single-threaded .xz decoder the only difference is
that LZMA_DATA_ERROR is detected in a difference place now.
2022-02-20 20:36:27 +02:00
Lasse Collin 555de11873 Tests: Add bad-1-lzma2-11.xz. 2022-02-20 19:38:55 +02:00
Lasse Collin f0da507f22 Translations: Fix po4a failure with the French man page translations.
Thanks to Mario Blättermann for the patch.
2022-02-18 18:51:10 +02:00
Lasse Collin f7711d228c Translations: Add French translation of man pages.
This matches xz-utils 5.2.5-2 in Debian.

The translation was done by "bubu", proofread by the debian-l10n-french
mailing list contributors, and submitted to me on the xz-devel mailing
list by Jean-Pierre Giraud. Thanks to everyone!
2022-02-07 01:30:06 +02:00
jiat75 6468f7e41a liblzma: Add NULL checks to LZMA and LZMA2 properties encoders.
Previously lzma_lzma_props_encode() and lzma_lzma2_props_encode()
assumed that the options pointers must be non-NULL because the
with these filters the API says it must never be NULL. It is
good to do these checks anyway.
2022-02-07 00:20:01 +02:00
Lasse Collin 2523c30705 liblzma: Fix uint64_t vs. size_t confusion.
This broke 32-bit builds due to a pointer type mismatch.

This bug was introduced with the output-size-limited encoding
in 625f4c7c99.

Thanks to huangqinjin for the bug report.
2022-02-06 23:19:32 +02:00
huangqinjin 2bd36c91d0 CMake: Keep compatible with Windows 95 for 32-bit build. 2022-02-06 22:49:39 +02:00
Lasse Collin 2024fbf279 xzgrep: Update man page timestamp. 2021-11-13 21:04:05 +02:00
Lasse Collin 400e7a239a Update THANKS. 2021-11-13 18:23:24 +02:00
Ville Skyttä 3a512c7787 xzgrep: use `grep -E/-F` instead of `egrep` and `fgrep`
`egrep` and `fgrep` have been deprecated in GNU grep since 2007, and in
current post 3.7 Git they have been made to emit obsolescence warnings:
https://git.savannah.gnu.org/cgit/grep.git/commit/?id=a9515624709865d480e3142fd959bccd1c9372d1
2021-11-13 18:17:33 +02:00
Lasse Collin edf525e2b1 Bump the version number for 5.3.2alpha. 2021-10-28 23:02:11 +03:00
Lasse Collin ea8c948655 Add NEWS for 5.3.2alpha. 2021-10-28 22:59:52 +03:00
Lasse Collin 52435f302f Update THANKS. 2021-10-27 23:27:48 +03:00
Lasse Collin f2aea1d5a5 xz: Change the coding style of the previous commit.
It isn't any better now but it's consistent with
the rest of the code base.
2021-10-27 23:23:11 +03:00
Alexander Bluhm 892b16cc28 xz: Avoid fchown(2) failure.
OpenBSD does not allow to change the group of a file if the user
does not belong to this group.  In contrast to Linux, OpenBSD also
fails if the new group is the same as the old one.  Do not call
fchown(2) in this case, it would change nothing anyway.

This fixes an issue with Perl Alien::Build module.
https://github.com/PerlAlien/Alien-Build/issues/62
2021-10-27 20:49:41 +03:00
Lasse Collin 2b509c868c liblzma: Fix liblzma.map for the lzma_microlzma_* symbols.
This should have been part of d267d109c3.

Thanks to Gao Xiang.
2021-09-17 17:31:11 +03:00
Lasse Collin cacb06a954 Update THANKS. 2021-09-09 22:21:07 +03:00
Lasse Collin 6928aac9da liblzma: Use _MSVC_LANG to detect when "noexcept" can be used with MSVC.
By default, MSVC always sets __cplusplus to 199711L. The real
C++ standard version is available in _MSVC_LANG (or one could
use /Zc:__cplusplus to set __cplusplus correctly).

Fixes <https://sourceforge.net/p/lzmautils/discussion/708858/thread/f6bc3b108a/>.

Thanks to Dan Weiss.
2021-09-09 21:41:51 +03:00
Lasse Collin d267d109c3 liblzma: Rename EROFS LZMA to MicroLZMA.
It still exists primarily for EROFS but MicroLZMA is
a more generic name (that hopefully doesn't clash with
something that already exists).
2021-09-05 20:38:12 +03:00
Lasse Collin 3247e95115 xzdiff: Update the man page about the exit status.
This was forgotten from 194029ffaf.
2021-06-04 19:02:38 +03:00
Lasse Collin 96f5a28a46 xzless: Fix less(1) version detection when it contains a dot.
Sometimes the version number from "less -V" contains a dot,
sometimes not. xzless failed detect the version number when
it does contain a dot. This fixes it.

Thanks to nick87720z for reporting this. Apparently it had been
reported here <https://bugs.gentoo.org/489362> in 2013.
2021-06-04 18:52:48 +03:00
Lasse Collin 5fb5212d81 Update THANKS. 2021-04-11 19:58:10 +03:00
Ivan A. Melnikov fc3d3a7296 Reduce maximum possible memory limit on MIPS32
Due to architectural limitations, address space available to a single
userspace process on MIPS32 is limited to 2 GiB, not 4, even on systems
that have more physical RAM -- e.g. 64-bit systems with 32-bit
userspace, or systems that use XPA (an extension similar to x86's PAE).

So, for MIPS32, we have to impose stronger memory limits. I've chosen
2000MiB to give the process some headroom.
2021-04-11 19:50:41 +03:00
Lasse Collin e7da44d515 CMake: Use interface library for better FindLibLZMA compatibility.
https://www.mail-archive.com/xz-devel@tukaani.org/msg00446.html

Thanks to Markus Rickert.
2021-02-13 23:31:27 +02:00
Lasse Collin a61dd82ada CMake: Try to improve compatibility with the FindLibLZMA module.
The naming conflict with FindLibLZMA module gets worse.
Not avoiding it in the first place was stupid.

Normally find_package(LibLZMA) will use the module and
find_package(liblzma 5.2.5 REQUIRED CONFIG) will use the config
file even with a case insensitive file system. However, if
CMAKE_FIND_PACKAGE_PREFER_CONFIG is TRUE and the file system
is case insensitive, find_package(LibLZMA) will find our liblzma
config file instead of using FindLibLZMA module.

One big problem with this is that FindLibLZMA uses
LibLZMA::LibLZMA and we use liblzma::liblzma as the target
name. With target names CMake happens to be case sensitive.
To workaround this, this commit adds

    add_library(LibLZMA::LibLZMA ALIAS liblzma::liblzma)

to the config file. Then both spellings work.

To make the behavior consistent between case sensitive and
insensitive file systems, the config and related files are
renamed from liblzmaConfig.cmake to liblzma-config.cmake style.
With this style CMake looks for lowercase version of the package
name so find_package(LiBLzmA 5.2.5 REQUIRED CONFIG) will work
to find our config file.

There are other differences between our config file and
FindLibLZMA so it's still possible that things break for
reasons other than the spelling of the target name. Hopefully
those situations aren't too common.

When the config file is available, it should always give as good or
better results as FindLibLZMA so this commit doesn't affect the
recommendation to use find_package(liblzma 5.2.5 REQUIRED CONFIG)
which explicitly avoids FindLibLZMA.

Thanks to Markus Rickert.
2021-01-30 18:36:04 +02:00
Lasse Collin 5b7bc1b8ae Update THANKS. 2021-01-29 21:19:43 +02:00
Lasse Collin 6c6f0db340 liblzma: Fix unitialized variable.
This was introduced two weeks ago in the commit
625f4c7c99.

Thanks to Nathan Moinvaziri.
2021-01-29 21:19:08 +02:00
Lasse Collin bb1d5c1fdd Tests: Add bad-1-lzma2-10.xz and also modify -9.xz. 2021-01-24 22:32:41 +02:00
Lasse Collin 6b8abc84a5 liblzma: Fix a wrong comment in stream_encoder_mt.c. 2021-01-24 19:22:35 +02:00
Lasse Collin 939fc5ed65 Tests: Add bad-1-lzma2-9.xz. 2021-01-24 18:51:51 +02:00
Lasse Collin fdd30032f8 Tests: Add bad-1-check-crc32-2.xz. 2021-01-24 17:04:51 +02:00
Lasse Collin db465419ae liblzma: In EROFS LZMA decoder, verify that comp_size matches at the end.
When the uncompressed size is known to be exact, after decompressing
the stream exactly comp_size bytes of input must have been consumed.
This is a minor improvement to error detection.
2021-01-17 19:20:50 +02:00
Lasse Collin 774cc0118b liblzma: Make EROFS LZMA decoder work when exact uncomp_size isn't known.
The caller must still not specify an uncompressed size bigger
than the actual uncompressed size.

As a downside, this now needs the exact compressed size.
2021-01-17 18:53:34 +02:00
Lasse Collin 421b0aa352 liblzma: Fix missing normalization in rc_encode_dummy().
Without this fix it could attempt to create too much output.
2021-01-14 20:57:11 +02:00
Lasse Collin 601ec0311e liblzma: Add EROFS LZMA encoder and decoder.
Right now this is just a planned extra-compact format for use
in the EROFS file system in Linux. At this point it's possible
that the format will either change or be abandoned and removed
completely.

The special thing about the encoder is that it uses the
output-size-limited encoding added in the previous commit.
EROFS uses fixed-sized blocks (e.g. 4 KiB) to hold compressed
data so the compressors must be able to create valid streams
that fill the given block size.
2021-01-14 20:10:59 +02:00
Lasse Collin 625f4c7c99 liblzma: Add rough support for output-size-limited encoding in LZMA1.
With this it is possible to encode LZMA1 data without EOPM so that
the encoder will encode as much input as it can without exceeding
the specified output size limit. The resulting LZMA1 stream will
be a normal LZMA1 stream without EOPM. The actual uncompressed size
will be available to the caller via the uncomp_size pointer.

One missing thing is that the LZMA layer doesn't inform the LZ layer
when the encoding is finished and thus the LZ may read more input
when it won't be used. However, this doesn't matter if encoding is
done with a single call (which is the planned use case for now).
For proper multi-call encoding this should be improved.

This commit only adds the functionality for internal use.
Nothing uses it yet.
2021-01-14 18:58:13 +02:00
Lasse Collin 9cdabbeea8 Scripts: Add zstd support to xzdiff. 2021-01-11 23:57:11 +02:00
Lasse Collin d9ec3add97 Update THANKS. 2021-01-11 23:41:30 +02:00
Lasse Collin 074259f4f3 xz: Make --keep accept symlinks, hardlinks, and setuid/setgid/sticky.
Previously this required using --force but that has other
effects too which might be undesirable. Changing the behavior
of --keep has a small risk of breaking existing scripts but
since this is a fairly special corner case I expect the
likehood of breakage to be low enough.

I think the new behavior is more logical. The only reason for
the old behavior was to be consistent with gzip and bzip2.

Thanks to Vincent Lefevre and Sebastian Andrzej Siewior.
2021-01-11 23:41:16 +02:00
Lasse Collin 73c555b307 Scripts: Fix exit status of xzgrep.
Omit the -q option from xz, gzip, and bzip2. With xz this shouldn't
matter. With gzip it's important because -q makes gzip replace SIGPIPE
with exit status 2. With bzip2 it's important because with -q bzip2
is completely silent if input is corrupt while other decompressors
still give an error message.

Avoiding exit status 2 from gzip is important because bzip2 uses
exit status 2 to indicate corrupt input. Before this commit xzgrep
didn't recognize corrupt .bz2 files because xzgrep was treating
exit status 2 as SIGPIPE for gzip compatibility.

zstd still needs -q because otherwise it is noisy in normal
operation.

The code to detect real SIGPIPE didn't check if the exit status
was due to a signal (>= 128) and so could ignore some other exit
status too.
2021-01-11 23:28:52 +02:00
Lasse Collin 194029ffaf Scripts: Fix exit status of xzdiff/xzcmp.
This is a minor fix since this affects only the situation when
the files differ and the exit status is something else than 0.
In such case there could be SIGPIPE from a decompression tool
and that would result in exit status of 2 from xzdiff/xzcmp
while the correct behavior would be to return 1 or whatever
else diff or cmp may have returned.

This commit omits the -q option from xz/gzip/bzip2/lzop arguments.
I'm not sure why the -q was used in the first place, perhaps it
hides warnings in some situation that I cannot see at the moment.
Hopefully the removal won't introduce a new bug.

With gzip the -q option was harmful because it made gzip return 2
instead of >= 128 with SIGPIPE. Ignoring exit status 2 (warning
from gzip) isn't practical because bzip2 uses exit status 2 to
indicate corrupt input file. It's better if SIGPIPE results in
exit status >= 128.

With bzip2 the removal of -q seems to be good because with -q
it prints nothing if input is corrupt. The other tools aren't
silent in this situation even with -q. On the other hand, if
zstd support is added, it will need -q since otherwise it's
noisy in normal situations.

Thanks to Étienne Mollier and Sebastian Andrzej Siewior.
2021-01-11 22:58:58 +02:00
Lasse Collin f7fa309e1f liblzma: Make lzma_outq usable for threaded decompression too.
Before this commit all output queue buffers were allocated as
a single big allocation. Now each buffer is allocated separately
when needed. Used buffers are cached to avoid reallocation
overhead but the cache will keep only one buffer size at a time.
This should make things work OK in the decompression where most
of the time the buffer sizes will be the same but with some less
common files the buffer sizes may vary.

While this should work fine, it's still a bit preliminary
and may even get reverted if it turns out to be useless for
decompression.
2021-01-09 22:18:23 +02:00
Lasse Collin a35a69d693 Update THANKS. 2020-12-23 17:15:49 +02:00
H.J. Lu 4fd79b90c5 liblzma: Enable Intel CET in x86 CRC assembly codes
When Intel CET is enabled, we need to include <cet.h> in assembly codes
to mark Intel CET support and add _CET_ENDBR to indirect jump targets.

Tested on Intel Tiger Lake under CET enabled Linux.
2020-12-23 17:13:33 +02:00
Lasse Collin bb3b8c6a23 Update THANKS. 2020-12-16 18:33:29 +02:00
Lasse Collin 21588ca34a Build: Don't build bundles on Apple OSes.
Thanks to Daniel Packard.
2020-12-16 18:30:14 +02:00
Lasse Collin d05b0c42dd Update THANKS. 2020-12-05 22:44:03 +02:00
Adam Borowski 1890351f34 Scripts: Add zstd support to xzgrep.
Thanks to Adam Borowski.
2020-12-05 22:39:03 +02:00
Lasse Collin 2f108abb3d CMake: Fix compatibility with CMake 3.13.
The syntax "if(DEFINED CACHE{FOO})" requires CMake 3.14.
In some other places the code treats the cache variables
like normal variables already (${FOO} or if(FOO) is used,
not ${CACHE{FOO}).

Thanks to ygrek for reporting the bug on IRC.
2020-11-17 21:09:39 +02:00
Lasse Collin 5af726a792 Update THANKS. 2020-11-01 22:56:43 +02:00
Lasse Collin 4575d9d365 xz: Avoid unneeded \f escapes on the man page.
I don't want to use \c in macro arguments but groff_man(7)
suggests that \f has better portability. \f would be needed
for the .TP strings for portability reasons anyway.

Thanks to Bjarni Ingi Gislason.
2020-11-01 22:34:25 +02:00
Lasse Collin 620b32f533 xz: Use non-breaking spaces when intentionally using more than one space.
This silences some style checker warnings. Seems that spaces
in the beginning of a line don't need this treatment.

Thanks to Bjarni Ingi Gislason.
2020-11-01 19:09:53 +02:00
Lasse Collin cb1f34988c xz: Protect the ellipsis (...) on the man page with \&.
This does it only when ... appears outside macro calls.

Thanks to Bjarni Ingi Gislason.
2020-11-01 18:53:25 +02:00
Lasse Collin 5d224da3da xz: Avoid the abbreviation "e.g." on the man page.
A few are simply omitted, most are converted to "for example"
and surrounded with commas. Sounds like that this is better
style, for example, man-pages(7) recommends avoiding such
abbreviations except in parenthesis.

Thanks to Bjarni Ingi Gislason.
2020-11-01 18:44:51 +02:00
Lasse Collin 90457dbe3e xz man page: Change \- (minus) to \(en (en-dash) for a numeric range.
Docs of ancient troff/nroff mention \(em (em-dash) but not \(en
and \- was used for both minus and en-dash. I don't know how
portable \(en is nowadays but it can be changed back if someone
complains. At least GNU groff and OpenBSD's mandoc support it.

Thanks to Bjarni Ingi Gislason for the patch.
2020-07-12 23:10:03 +03:00
Lasse Collin 352ba2d69a Windows: Fix building of resource files when config.h isn't used.
Now CMake + Visual Studio works for building liblzma.dll.

Thanks to Markus Rickert.
2020-07-12 20:46:24 +03:00
Lasse Collin a9e2a87f1d src/scripts/xzgrep.1: Filenames to xzgrep are optional.
xzgrep --help was correct already.
2020-04-06 19:34:48 +03:00
Bjarni Ingi Gislason a7ba275d9b src/script/xzgrep.1: Remove superfluous '.RB'
Output is from: test-groff -b -e -mandoc -T utf8 -rF0 -t -w w -z

  [ "test-groff" is a developmental version of "groff" ]

Input file is ./src/scripts/xzgrep.1

<src/scripts/xzgrep.1>:20 (macro RB): only 1 argument, but more are expected
<src/scripts/xzgrep.1>:23 (macro RB): only 1 argument, but more are expected
<src/scripts/xzgrep.1>:26 (macro RB): only 1 argument, but more are expected
<src/scripts/xzgrep.1>:29 (macro RB): only 1 argument, but more are expected
<src/scripts/xzgrep.1>:32 (macro RB): only 1 argument, but more are expected

 "abc..." does not mean the same as "abc ...".

  The output from nroff and troff is unchanged except for the space
between "file" and "...".

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2020-04-06 19:29:15 +03:00
Bjarni Ingi Gislason 133d498db0 xzgrep.1: Delete superfluous '.PP'
Summary:

mandoc -T lint xzgrep.1 :
mandoc: xzgrep.1:79:2: WARNING: skipping paragraph macro: PP empty

  There is no change in the output of "nroff" and "troff".

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2020-04-06 19:08:14 +03:00
Bjarni Ingi Gislason 057839ca98 src/xz/xz.1: Correct misused two-fonts macros
Output is from: test-groff -b -e -mandoc -T utf8 -rF0 -t -w w -z

  [ "test-groff" is a developmental version of "groff" ]

Input file is ./src/xz/xz.1

<src/xz/xz.1>:408 (macro BR): only 1 argument, but more are expected
<src/xz/xz.1>:1009 (macro BR): only 1 argument, but more are expected
<src/xz/xz.1>:1743 (macro BR): only 1 argument, but more are expected
<src/xz/xz.1>:1920 (macro BR): only 1 argument, but more are expected
<src/xz/xz.1>:2213 (macro BR): only 1 argument, but more are expected

  Output from nroff and troff is unchanged, except for a font change of a
full stop (.).

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2020-04-06 19:08:04 +03:00
Lasse Collin b8e12f5ab4 Typo fixes from fossies.org.
https://fossies.org/linux/misc/xz-5.2.5.tar.xz/codespell.html
2020-03-23 18:07:50 +02:00
Lasse Collin 869b9d1b4e Update NEWS for 5.2.5. 2020-03-17 16:24:28 +02:00
Lasse Collin a048e3a92d README: Update outdated sections. 2020-03-16 20:01:37 +02:00
Lasse Collin 29aed815ad README: Mention that man pages can be translated. 2020-03-16 19:39:45 +02:00
Lasse Collin 7fa7653940 Update INSTALL.generic from Automake 1.16.1. 2020-03-16 16:43:29 +02:00
Lasse Collin 9bd317ef03 Update INSTALL for Windows and DOS and add preliminary info for z/OS. 2020-03-15 15:27:22 +02:00
Lasse Collin a3148c0446 Build: Update m4/ax_pthread.m4 from Autoconf Archive (again). 2020-03-15 15:26:20 +02:00
Lasse Collin 7812002dd3 xz: Never use thousand separators in DJGPP builds.
DJGPP 2.05 added support for thousands separators but it's
broken at least under WinXP with Finnish locale that uses
a non-breaking space as the thousands separator. Workaround
by disabling thousands separators for DJGPP builds.
2020-03-11 21:15:35 +02:00
Lasse Collin 7c8f688bf7 DOS: Update dos/Makefile for DJGPP 2.05.
It doesn't need -fgnu89-inline like 2.04beta did.
2020-03-11 19:38:08 +02:00
Lasse Collin 319ca928d7 DOS: Update instructions in dos/INSTALL.txt. 2020-03-11 19:36:07 +02:00
Lasse Collin cb6b227ce3 DOS: Update config.h.
The added defines assume GCC >= 4.8.
2020-03-11 17:58:51 +02:00
Lasse Collin 4572d53e16 liblzma: Fix a comment and RC_SYMBOLS_MAX.
The comment didn't match the value of RC_SYMBOLS_MAX and the value
itself was slightly larger than actually needed. The only harm
about this was that memory usage was a few bytes larger.
2020-03-02 13:54:33 +02:00
Lasse Collin 265daa873c Build: Make CMake build fail if tuklib_cpucores or tuklib_physmem fails. 2020-02-27 20:58:52 +02:00
Lasse Collin 7c8b904527 Build: Add support for --no-po4a option to autogen.sh.
Normally, if po4a isn't available, autogen.sh will return
with non-zero exit status. The option --no-po4a can be useful
when one knows that po4a isn't available but wants autogen.sh
to still return with zero exit status.
2020-02-27 20:24:27 +02:00
Lasse Collin 292a5c0f9c Update THANKS. 2020-02-25 21:35:14 +02:00
Lasse Collin 474320e990 Build: Fix bugs in the CMake files.
Seems that the phrase "add more quotes" from sh/bash scripting
applies to CMake as well. E.g. passing an unquoted list ${FOO}
to a function that expects one argument results in only the
first element of the list being passed as an argument and
the rest get ignored. Adding quotes helps ("${FOO}").

list(INSERT ...) is weird. Inserting an empty string to an empty
variable results in empty list, but inserting it to a non-empty
variable does insert an empty element to the list.

Since INSERT requires at least one element,
"${CMAKE_THREAD_LIBS_INIT}" needs to be quoted in CMakeLists.txt.
It might result in an empty element in the list. It seems to not
matter as empty elements consistently get ignored in that variable.
In fact, calling cmake_check_push_state() and cmake_check_pop_state()
will strip the empty elements from CMAKE_REQUIRED_LIBRARIES!

In addition to quoting fixes, this fixes checks for the cache
variables in tuklib_cpucores.cmake and tuklib_physmem.cmake.

Thanks to Martin Matuška for testing and reporting the problems.
These fixes aren't tested yet but hopefully they soon will be.
2020-02-25 20:44:10 +02:00
Lasse Collin 7e3493d40e Build: Add very limited experimental CMake support.
This does *NOT* replace the Autotools-based build system in
the foreseeable future. See the comment in the beginning
of CMakeLists.txt.

So far this has been tested only on GNU/Linux but I commit
it anyway to make it easier for others to test. Since I
haven't played much with CMake before, it's likely that
there are things that have been done in a silly or wrong
way and need to be fixed.
2020-02-25 00:00:32 +02:00
Lasse Collin 21bd4701fc Update m4/.gitignore. 2020-02-24 23:37:07 +02:00
Lasse Collin e094d1d0f1 tuklib: Omit an unneeded <sys/types.h> from a tests.
tuklib_cpucores.c and tuklib_physmem.c don't include <sys/types.h>
even via other files in this package, so clearly that header isn't
needed in the tests either (no one has reported build problems due
to a missing header in a .c file).
2020-02-24 23:34:58 +02:00
Lasse Collin b3ed19a55f liblzma: Remove unneeded <sys/types.h> from fastpos_tablegen.c.
This file only generates fastpos_table.c.
It isn't built as a part of liblzma.
2020-02-24 23:23:18 +02:00
Lasse Collin 7b8982b291 Use defined(__GNUC__) before __GNUC__ in preprocessor lines.
This should silence the equivalent of -Wundef in compilers that
don't define __GNUC__.
2020-02-22 14:15:07 +02:00
Lasse Collin 43dfe04e62 liblzma: Add more uses of lzma_memcmplen() to the normal mode of LZMA.
This gives a tiny encoder speed improvement. This could have been done
in 2014 after the commit 544aaa3d13 but
it was forgotten.
2020-02-21 17:40:02 +02:00
Lasse Collin 59e6eb4840 Build: Add visibility.m4 from gnulib.
Appears that this file used to get included as a side effect of
gettext. After the change to gettext version requirements this file
no longer got copied to the package and so the build was broken.
2020-02-21 17:01:15 +02:00
Lasse Collin 7fe3ef2eaa xz: Silence a warning when sig_atomic_t is long int.
It can be true at least on z/OS.
2020-02-21 16:10:44 +02:00
Lasse Collin b0a2a77d10 xz: Avoid unneeded access of a volatile variable. 2020-02-21 15:59:26 +02:00
Lasse Collin 524c2f12c7 tuklib_integer.m4: Optimize the check order.
The __builtin byteswapping is the preferred one so check for it first.
2020-02-21 01:24:18 +02:00
Lasse Collin 57360bb4fd tuklib_exit: Add missing header.
strerror() needs <string.h> which happened to be included via
tuklib_common.h -> tuklib_config.h -> sysdefs.h if HAVE_CONFIG_H
was defined. This wasn't tested without config.h before so it
had worked fine.
2020-02-20 18:54:04 +02:00
Lasse Collin fddd31175e Revert the previous commit and add a comment.
The previous commit broke crc32_tablegen.c.

If the whole package is built without config.h (with defines
set on the compiler command line) this should still work fine
as long as these headers conform to C99 well enough.
2020-02-18 19:12:35 +02:00
Lasse Collin 4e4e9fbb7e Do not check for HAVE_CONFIG_H in tuklib_config.h.
In XZ Utils sysdefs.h takes care of it and the required headers.
2020-02-17 23:37:20 +02:00
Lasse Collin 2d4cef954f sysdefs.h: Omit the conditionals around string.h and limits.h.
string.h is used unconditionally elsewhere in the project and
configure has always stopped if limits.h is missing, so these
headers must have been always available even on the weirdest
systems.
2020-02-16 12:24:13 +02:00
Lasse Collin feb9c1969b Build: Bump Autoconf and Libtool version requirements.
There is no specific reason for this other than blocking
the most ancient versions. These are still old:

Autoconf 2.69 (2012)
Automake 1.12 (2012)
gettext 0.19.6 (2015)
Libtool 2.4 (2010)
2020-02-15 15:07:11 +02:00
Lasse Collin 3d576cf921 Build: Use AM_GNU_GETTEXT_REQUIRE_VERSION and require 0.19.6.
This bumps the version requirement from 0.19 (from 2014) to
0.19.6 (2015).

Using only the old AM_GNU_GETTEXT_VERSION results in old
gettext infrastructure being placed in the package. By using
both macros we get the latest gettext files while the other
programs in the Autotools family can still see the old macro.
2020-02-15 15:05:35 +02:00
Lasse Collin fa792b8bef Translations: Add German translation of the man pages.
Thanks to Mario Blättermann.
2020-02-14 21:26:05 +02:00
Lasse Collin 6f7211b6bb Build: Add support for translated man pages using po4a.
The dependency on po4a is optional. It's never required to install
the translated man pages when xz is built from a release tarball.
If po4a is missing when building from xz.git, the translated man
pages won't be generated but otherwise the build will work normally.

The translations are only updated automatically by autogen.sh and
by "make mydist". This makes it easy to keep po4a as an optional
dependency and ensures that I won't forget to put updated
translations to a release tarball.

The translated man pages aren't installed if --disable-nls is used.

The installation of translated man pages abuses Automake internals
by calling "install-man" with redefined dist_man_MANS and man_MANS.
This makes the hairy script code slightly less hairy. If it breaks
some day, this code needs to be fixed; don't blame Automake developers.

Also, this adds more quotes to the existing shell script code in
the Makefile.am "-hook"s.
2020-02-07 15:32:21 +02:00
Lasse Collin 426f9e5819 Update THANKS. 2020-02-06 17:31:38 +02:00
Lasse Collin e3a4481d02 Update tests/.gitignore. 2020-02-05 22:35:06 +02:00
Lasse Collin 07208de92f Update m4/.gitignore. 2020-02-05 22:28:51 +02:00
Lasse Collin c91fbf223d Update THANKS. 2020-02-05 20:47:38 +02:00
Lasse Collin 15a133b6d1 xz: Make it a fatal error if enabling the sandbox fails.
Perhaps it's too drastic but on the other hand it will let me
learn about possible problems if people report the errors.
This won't be backported to the v5.2 branch.
2020-02-05 20:40:14 +02:00
Lasse Collin af0fb386ef xz: Comment out annoying sandboxing messages. 2020-02-05 20:33:50 +02:00
Lasse Collin 986d8c9b52 Build: Workaround a POSIX shell detection problem on Solaris.
I don't know if the problem is in gnulib's gl_POSIX_SHELL macro
or if xzgrep does something that isn't in POSIX. The workaround
adds a special case for Solaris: if /usr/xpg4/bin/sh exists and
gl_cv_posix_shell wasn't overriden on the configure command line,
use that shell for xzgrep and other scripts. That shell is known
to work and exists on most Solaris systems.
2020-02-05 19:33:37 +02:00
Lasse Collin 6629ed929c Build: Update m4/ax_pthread.m4 from Autoconf Archive. 2020-02-03 22:03:50 +02:00
Lasse Collin 3539705108 xz: Limit --memlimit-compress to at most 4020 MiB for 32-bit xz.
See the code comment for reasoning. It's far from perfect but
hopefully good enough for certain cases while hopefully doing
nothing bad in other situations.

At presets -5 ... -9, 4020 MiB vs. 4096 MiB makes no difference
on how xz scales down the number of threads.

The limit has to be a few MiB below 4096 MiB because otherwise
things like "xz --lzma2=dict=500MiB" won't scale down the dict
size enough and xz cannot allocate enough memory. With
"ulimit -v $((4096 * 1024))" on x86-64, the limit in xz had
to be no more than 4085 MiB. Some safety margin is good though.

This is hack but it should be useful when running 32-bit xz on
a 64-bit kernel that gives full 4 GiB address space to xz.
Hopefully this is enough to solve this:

https://bugzilla.redhat.com/show_bug.cgi?id=1196786

FreeBSD has a patch that limits the result in tuklib_physmem()
to SIZE_MAX on 32-bit systems. While I think it's not the way
to do it, the results on --memlimit-compress have been good. This
commit should achieve practically identical results for compression
while leaving decompression and tuklib_physmem() and thus
lzma_physmem() unaffected.
2020-02-01 19:56:18 +02:00
Lasse Collin ba76d67585 xz: Set the --flush-timeout deadline when the first input byte arrives.
xz --flush-timeout=2000, old version:

  1. xz is started. The next flush will happen after two seconds.
  2. No input for one second.
  3. A burst of a few kilobytes of input.
  4. No input for one second.
  5. Two seconds have passed and flushing starts.

The first second counted towards the flush-timeout even though
there was no pending data. This can cause flushing to occur more
often than needed.

xz --flush-timeout=2000, after this commit:

  1. xz is started.
  2. No input for one second.
  3. A burst of a few kilobytes of input. The next flush will
     happen after two seconds counted from the time when the
     first bytes of the burst were read.
  4. No input for one second.
  5. No input for another second.
  6. Two seconds have passed and flushing starts.
2020-01-26 20:53:25 +02:00
Lasse Collin fd47fd62bb xz: Move flush_needed from mytime.h to file_pair struct in file_io.h. 2020-01-26 20:25:52 +02:00
Lasse Collin 8150356810 xz: coder.c: Make writing output a separate function.
The same code sequence repeats so it's nicer as a separate function.
Note that in one case there was no test for opt_mode != MODE_TEST,
but that was only because that condition would always be true, so
this commit doesn't change the behavior there.
2020-01-26 14:49:22 +02:00
Lasse Collin 5a49e081a0 xz: Fix semi-busy-waiting in xz --flush-timeout.
When input blocked, xz --flush-timeout=1 would wake up every
millisecond and initiate flushing which would have nothing to
flush and thus would just waste CPU time. The fix disables the
timeout when no input has been seen since the previous flush.
2020-01-26 14:13:42 +02:00
Lasse Collin dcca70fe9f xz: Refactor io_read() a bit. 2020-01-26 13:47:31 +02:00
Lasse Collin 4ae9ab70cd xz: Update a comment in file_io.h. 2020-01-26 13:37:08 +02:00
Lasse Collin 3333ba4a67 xz: Move the setting of flush_needed in file_io.c to a nicer location. 2020-01-26 13:27:51 +02:00
Lasse Collin cf2df0f05a Use $(LIB_FUZZING_ENGINE) in tests/ossfuzz/Makefile.
https://github.com/google/oss-fuzz/pull/3219#issuecomment-573751048

Thanks to Bhargava Shastry for sending the patch.
2020-01-19 21:54:33 +02:00
Lasse Collin 7136f1735c Rename unaligned_read32ne to read32ne, and similarly for the others. 2019-12-31 00:47:49 +02:00
Lasse Collin 5e78fcbf2e Rename read32ne to aligned_read32ne, and similarly for the others.
Using the aligned methods requires more care to ensure that
the address really is aligned, so it's nicer if the aligned
methods are prefixed. The next commit will remove the unaligned_
prefix from the unaligned methods which in liblzma are used in
more places than the aligned ones.
2019-12-31 00:29:48 +02:00
Lasse Collin 77bc5bc6dd Revise tuklib_integer.h and .m4.
Add a configure option --enable-unsafe-type-punning to get the
old non-conforming memory access methods. It can be useful with
old compilers or in some other less typical situations but
shouldn't normally be used.

Omit the packed struct trick for unaligned access. While it's
best in some cases, this is simpler. If the memcpy trick doesn't
work, one can request unsafe type punning from configure.

Because CRC32/CRC64 code needs fast aligned reads, if no very
safe way to do it is found, type punning is used as a fallback.
This sucks but since it currently works in practice, it seems to
be the least bad option. It's never needed with GCC >= 4.7 or
Clang >= 3.6 since these support __builtin_assume_aligned and
thus fast aligned access can be done with the memcpy trick.

Other things:
  - Support GCC/Clang __builtin_bswapXX
  - Cleaner bswap fallback macros
  - Minor cleanups
2019-12-31 00:18:24 +02:00
Lasse Collin 8b72950a6b Tests: Hopefully fix test_check.c to work on EBCDIC systems.
Thanks to Daniel Richard G.
2019-12-29 22:51:58 +02:00
Lasse Collin 43ce4ea7c7 Scripts: Put /usr/xpg4/bin to the beginning of PATH on Solaris.
This adds a configure option --enable-path-for-scripts=PREFIX
which defaults to empty except on Solaris it is /usr/xpg4/bin
to make POSIX grep and others available. The Solaris case had
been documented in INSTALL with a manual fix but it's better
to do this automatically since it is needed on most Solaris
systems anyway.

Thanks to Daniel Richard G.
2019-09-24 23:02:40 +03:00
Lasse Collin 6a89e656eb Fix comment typos in tuklib_mbstr* files. 2019-07-12 18:57:43 +03:00
Lasse Collin ac0b421265 Add missing include to tuklib_mbstr_width.c.
It didn't matter in XZ Utils because sysdefs.h
includes string.h anyway.
2019-07-12 18:30:46 +03:00
Lasse Collin 72a443281f Update tuklib base headers to include stdbool.h. 2019-07-12 18:10:57 +03:00
Lasse Collin de1f47b2b4 xz: Automatically align the strings in --info-memory.
This makes it easier to translate the strings.

Also, the string for amount of RAM was shortened.
2019-06-28 00:54:31 +03:00
Lasse Collin 8ce679125d liblzma: Fix a buggy comment. 2019-06-25 23:15:21 +03:00
Lasse Collin fc77929e92 configure.ac: Fix a typo in a comment. 2019-06-25 00:16:06 +03:00
Lasse Collin e873902641 Tests: Silence warnings from clang -Wassign-enum.
Also changed 999 to 99 so it fits even if lzma_check happened
to be 8 bits wide.
2019-06-25 00:08:13 +03:00
Lasse Collin d499e467d9 liblzma: Add a comment. 2019-06-24 23:52:17 +03:00
Lasse Collin a12b13c5f0 liblzma: Silence clang -Wmissing-variable-declarations. 2019-06-24 23:45:21 +03:00
Lasse Collin 1b4675cebf Add LZMA_RET_INTERNAL1..8 to lzma_ret and use one for LZMA_TIMED_OUT.
LZMA_TIMED_OUT is *internally* used as a value for lzma_ret
enumeration. Previously it was #defined to 32 and cast to lzma_ret.
That way it wasn't visible in the public API, but this was hackish.

Now the public API has eight LZMA_RET_INTERNALx members and
LZMA_TIMED_OUT is #defined to LZMA_RET_INTERNAL1. This way
the code is cleaner overall although the public API has a few
extra mysterious enum members.
2019-06-24 23:25:41 +03:00
Lasse Collin 159c43875e xz: Silence a warning from clang -Wsign-conversion in main.c. 2019-06-24 22:57:43 +03:00
Lasse Collin 466cfcd3e5 xz: Make "headings" static in list.c.
Caught by clang -Wmissing-variable-declarations.
2019-06-24 22:52:20 +03:00
Lasse Collin 608517b9b7 liblzma: Remove incorrect uses of lzma_attribute((__unused__)).
Caught by clang -Wused-but-marked-unused.
2019-06-24 22:50:36 +03:00
Lasse Collin c2d2ab6a9d Tests: Silence a warning from -Wsign-conversion. 2019-06-24 20:53:55 +03:00
Lasse Collin 2402f7873d xz: Fix an integer overflow with 32-bit off_t.
Or any off_t which isn't very big (like signed 64 bit integer
that most system have). A small off_t could overflow if the
file being decompressed had long enough run of zero bytes,
which would result in corrupt output.
2019-06-24 20:45:49 +03:00
Lasse Collin 4fd3a8dd0b xz: Cleanup io_seek_src() a bit.
lseek() returns -1 on error and checking for -1 is nicer.
2019-06-24 01:24:17 +03:00
Lasse Collin dfda7cf6af Tests: Remove a duplicate branch from tests/tests.h.
The duplication was introduced about eleven years ago and
should have been cleaned up back then already.

This was caught by -Wduplicated-branches.
2019-06-24 00:57:23 +03:00
Lasse Collin 1d4a904d8f xz: Change io_seek_src and io_pread arguments from off_t to uint64_t.
This helps fixing warnings from -Wsign-conversion and makes the
code look better too.
2019-06-24 00:40:45 +03:00
Lasse Collin 50120deb01 xz: list.c: Fix some warnings from -Wsign-conversion. 2019-06-24 00:12:38 +03:00
Lasse Collin d0a78751eb tuklib_mbstr_width: Fix a warning from -Wsign-conversion. 2019-06-23 23:22:45 +03:00
Lasse Collin 7883d73530 xz: Fix some of the warnings from -Wsign-conversion. 2019-06-23 23:19:34 +03:00
Lasse Collin c2b994fe3d tuklib_cpucores: Silence warnings from -Wsign-conversion. 2019-06-23 22:27:45 +03:00
Lasse Collin 07c4fa9e1a xzdec: Fix warnings from -Wsign-conversion. 2019-06-23 21:40:47 +03:00
Lasse Collin dfac2c9a1d liblzma: Fix warnings from -Wsign-conversion.
Also, more parentheses were added to the literal_subcoder
macro in lzma_comon.h (better style but no functional change
in the current usage).
2019-06-23 21:38:56 +03:00
Lasse Collin 41838dcc26 tuklib_integer: Silence warnings from -Wsign-conversion. 2019-06-23 19:33:55 +03:00
Lasse Collin 3ce05d235f tuklib_integer: Fix usage of conv macros.
Use a temporary variable instead of e.g.
conv32le(unaligned_read32ne(buf)) because the macro can
evaluate its argument multiple times.
2019-06-20 19:40:30 +03:00
Lasse Collin b525b0c0ef Update THANKS. 2019-06-03 20:44:19 +03:00
Lasse Collin 039a168e8c liblzma: Fix comments.
Thanks to Bruce Stark.
2019-06-03 20:41:54 +03:00
Lasse Collin c460f6defe liblzma: Fix one more unaligned read to use unaligned_read16ne(). 2019-06-02 00:50:59 +03:00
Lasse Collin c81d77c537 Update THANKS. 2019-06-01 21:41:55 +03:00
Lasse Collin 386394fc9f liblzma: memcmplen: Use ctz32() from tuklib_integer.h.
The same compiler-specific #ifdefs are already in tuklib_integer.h
2019-06-01 21:36:13 +03:00
Lasse Collin 264ab971ce tuklib_integer: Cleanup MSVC-specific code. 2019-06-01 21:30:03 +03:00
Lasse Collin 33773c6f2a liblzma: Use unaligned_readXXne functions instead of type punning.
Now gcc -fsanitize=undefined should be clean.

Thanks to Jeffrey Walton.
2019-06-01 19:01:21 +03:00
Lasse Collin e5f13a6656 tuklib_integer: Autodetect support for unaligned access on ARM.
The result is used as the default for --enable-unaligned-access.
The test should work with GCC and Clang.
2019-06-01 18:46:54 +03:00
Lasse Collin 3bc112c2d3 tuklib_integer: Improve unaligned memory access.
Now memcpy() or GNU C packed structs for unaligned access instead
of type punning. See the comment in this commit for details.

Avoiding type punning with unaligned access is needed to
silence gcc -fsanitize=undefined.

New functions: unaliged_readXXne and unaligned_writeXXne where
XX is 16, 32, or 64.
2019-06-01 18:41:16 +03:00
Lasse Collin 2a22de439e liblzma: Avoid memcpy(NULL, foo, 0) because it is undefined behavior.
I should have always known this but I didn't. Here is an example
as a reminder to myself:

    int mycopy(void *dest, void *src, size_t n)
    {
        memcpy(dest, src, n);
        return dest == NULL;
    }

In the example, a compiler may assume that dest != NULL because
passing NULL to memcpy() would be undefined behavior. Testing
with GCC 8.2.1, mycopy(NULL, NULL, 0) returns 1 with -O0 and -O1.
With -O2 the return value is 0 because the compiler infers that
dest cannot be NULL because it was already used with memcpy()
and thus the test for NULL gets optimized out.

In liblzma, if a null-pointer was passed to memcpy(), there were
no checks for NULL *after* the memcpy() call, so I cautiously
suspect that it shouldn't have caused bad behavior in practice,
but it's hard to be sure, and the problematic cases had to be
fixed anyway.

Thanks to Jeffrey Walton.
2019-05-13 20:05:17 +03:00
Lasse Collin d3fc850cfe Update THANKS. 2019-05-11 20:56:08 +03:00
Lasse Collin 4adb8288ab xz: Update xz man page date. 2019-05-11 20:54:12 +03:00
Antoine Cœur 2fb0ddaa55 spelling 2019-05-11 20:52:37 +03:00
Lasse Collin 4ed3396061 xz: In xz -lvv look at the widths of the check names too.
Now the widths of the check names is used to adjust the width
of the Check column. This way there no longer is a need to restrict
the widths of the check names to be at most ten terminal-columns.
2019-05-01 18:43:10 +03:00
Lasse Collin 2f4281a100 xz: Fix xz -lvv column alignment to look at the translated strings. 2019-05-01 18:33:25 +03:00
Lasse Collin 01d01b7c7c Update THANKS. 2019-05-01 16:52:36 +03:00
Lasse Collin 64030c6b17 Windows: Update VS version in windows/vs2019/config.h. 2019-05-01 16:43:16 +03:00
Julien Marrec 2dc9117f5f Windows: Upgrade solution itself 2019-05-01 16:41:26 +03:00
Julien Marrec ac31413916 Windows: Upgrade solution with VS2019 2019-05-01 16:41:26 +03:00
Julien Marrec be25a0c37b Windows: Duplicate windows/vs2017 before upgrading 2019-05-01 16:40:52 +03:00
Lasse Collin d0e58b3a51 README: Update translation instructions.
XZ Utils is now part of the Translation Project
<https://translationproject.org/>.
2019-03-04 22:49:04 +02:00
Lasse Collin a750c35a7d xz: Automatically align column headings in xz -lvv. 2019-03-04 21:20:39 +02:00
Lasse Collin 6cb42e8aa1 xz: Automatically align strings ending in a colon in --list output.
This should avoid alignment errors in translations with these
strings.
2019-03-04 21:16:59 +02:00
Lasse Collin 1e3f29b62f Windows/VS2017: Omit WindowsTargetPlatformVersion from project files.
I understood that if a WTPV is specified, it's often wrong
because different VS installations have different SDK version
installed. Omitting the WTPV tag makes VS2017 default to
Windows SDK 8.1 which often is also missing, so in any case
people may need to specify the WTPV before building. But some
day in the future a missing WTPV tag will start to default to
the latest installed SDK which sounds reasonable:

https://developercommunity.visualstudio.com/content/problem/140294/windowstargetplatformversion-makes-it-impossible-t.html

Thanks to "dom".
2019-01-13 17:29:23 +02:00
Lasse Collin 4d86076332 Update THANKS. 2018-12-20 20:42:29 +02:00
Lasse Collin b55d79461d xz: Fix a crash in progress indicator when in passthru mode.
"xz -dcfv not_an_xz_file" crashed (all four options are
required to trigger it). It caused xz to call
lzma_get_progress(&strm, ...) when no coder was initialized
in strm. In this situation strm.internal is NULL which leads
to a crash in lzma_get_progress().

The bug was introduced when xz started using lzma_get_progress()
to get progress info for multi-threaded compression, so the
bug is present in versions 5.1.3alpha and higher.

Thanks to Filip Palian <Filip.Palian@pjwstk.edu.pl> for
the bug report.
2018-12-20 20:39:20 +02:00
Lasse Collin 4ae5526de0 xz: Update man page timestamp. 2018-11-22 17:20:31 +02:00
Pavel Raiskup 6a36d0d5f4 'have have' typos 2018-11-22 17:19:09 +02:00
Lasse Collin 9eca51ef80 Update THANKS. 2018-11-02 20:40:48 +02:00
Lasse Collin 106d1a663d Tests: Add a fuzz test program and a config file for OSS-Fuzz.
Thanks to Bhargava Shastry and Github user pdknsk.
2018-11-02 20:40:14 +02:00
Lasse Collin a18ae42a79 liblzma: Don't verify header CRC32s if building for fuzz testing.
FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION is #defined when liblzma
is being built for fuzz testing.

Most fuzzed inputs would normally get rejected because of incorrect
CRC32 and the actual header decoding code wouldn't get fuzzed.
Disabling CRC32 checks avoids this problem. The fuzzer program
must still use LZMA_IGNORE_CHECK flag to disable verification of
integrity checks of uncompressed data.
2018-10-26 22:49:10 +03:00
Lasse Collin f76f7516d6 xzless: Rename unused variables to silence static analysers.
In this particular case I don't see this affecting readability
of the code.

Thanks to Pavel Raiskup.
2018-07-27 18:10:44 +03:00
Lasse Collin 3cbcaeb07e liblzma: Remove an always-true condition from lzma_index_cat().
This should help static analysis tools to see that newg
isn't leaked.

Thanks to Pavel Raiskup.
2018-07-27 16:02:58 +03:00
Lasse Collin 76762ae609 liblzma: Improve lzma_properties_decode() API documentation. 2018-05-19 21:23:25 +03:00
Lasse Collin 2267f5b0d2 Bump the version number to 5.3.1alpha. 2018-04-29 18:58:19 +03:00
Lasse Collin cee3021d30 extra/scanlzma: Fix compiler warnings. 2018-04-29 18:48:00 +03:00
Lasse Collin c5c7ceb08a DOS: Add file_info.c to the list of files to build. 2018-04-29 18:44:47 +03:00
Lasse Collin 114cab97af Update NEWS for 5.3.1alpha. 2018-04-29 18:33:10 +03:00
Lasse Collin b8139e11c5 Add NEWS for 5.2.4. 2018-04-29 18:30:48 +03:00
Lasse Collin 47b59d47cf Update THANKS. 2018-02-06 19:36:30 +02:00
Ben Boeckel bc19799169 nothrow: use noexcept for C++11 and newer
In C++11, the `throw()` specifier is deprecated and `noexcept` is
preffered instead.
2018-02-06 18:41:45 +02:00
Lasse Collin fb6d4f83cb liblzma: Remove incorrect #ifdef from range_common.h.
In most cases it was harmless but it could affect some
custom build systems.

Thanks to Pippijn van Steenhoven.
2018-02-06 18:02:48 +02:00
Lasse Collin bc577d35c2 Update THANKS. 2018-01-10 22:10:39 +02:00
Lasse Collin 713bbc1a80 tuklib_integer: New Intel C compiler needs immintrin.h.
Thanks to Melanie Blower (Intel) for the patch.
2018-01-10 21:54:27 +02:00
Lasse Collin a0ee1afbd9 Update THANKS. 2017-09-24 20:04:24 +03:00
Lasse Collin a1e2c568de Windows: Fix paths in VS project files.
Some paths use slashes instead of backslashes as directory
separators... now it should work (I tested VS2013 version).
2017-09-16 20:36:20 +03:00
Lasse Collin cea5cf8d26 Windows: Update VS2017 project files to include file info decoder. 2017-09-16 12:56:20 +03:00
Lasse Collin 95d563db3e Windows: Add project files for VS2017.
These files match the v5.2 branch (no file info decoder).
2017-09-16 12:56:05 +03:00
Lasse Collin ab72416d62 Windows: Update VS2013 project files to include file info decoder. 2017-09-16 12:45:50 +03:00
Lasse Collin 8238898018 Windows: Move VS2013 files into windows/vs2013 directory. 2017-09-16 12:44:06 +03:00
Lasse Collin 94e3f986aa Fix or hide warnings from GCC 7's -Wimplicit-fallthrough. 2017-08-14 20:08:33 +03:00
Alexey Tourbin 0b0e1e6803 Docs: Fix a typo in a comment in doc/examples/02_decompress.c. 2017-05-23 18:46:49 +03:00
Lasse Collin a015cd1f90 xz: Fix "xz --list --robot missing_or_bad_file.xz".
It ended up printing an uninitialized char-array when trying to
print the check names (column 7) on the "totals" line.

This also changes the column 12 (minimum xz version) to
50000002 (xz 5.0.0) instead of 0 when there are no valid
input files.

Thanks to kidmin for the bug report.
2017-05-23 18:34:43 +03:00
Lasse Collin c2e29f06a7 Docs: Add doc/examples/11_file_info.c. 2017-04-24 20:20:11 +03:00
Lasse Collin 1520f6ec80 Build: Omit pre-5.0.0 entries from the generated ChangeLog.
It makes ChangeLog significantly smaller.
2017-04-24 19:48:47 +03:00
Lasse Collin 8269782283 xz: Use lzma_file_info_decoder() for --list. 2017-04-24 19:48:23 +03:00
Lasse Collin e353d0b1cc liblzma: Add lzma_file_info_decoder(). 2017-04-24 19:48:04 +03:00
Lasse Collin 144ef9e19e Update the Git repository URL to HTTPS in ChangeLog. 2017-04-24 19:30:22 +03:00
Lasse Collin 8c9842c265 liblzma: Rename LZMA_SEEK to LZMA_SEEK_NEEDED and seek_in to seek_pos. 2017-04-21 15:05:16 +03:00
Lasse Collin 662b27c417 Update the home page URLs to HTTPS. 2017-04-19 22:17:35 +03:00
Lasse Collin c28f0b3d00 xz: Add io_seek_src(). 2017-04-05 18:47:22 +03:00
Lasse Collin bba477257d xz: Use POSIX_FADV_RANDOM for in "xz --list" mode.
xz --list is random access so POSIX_FADV_SEQUENTIAL was clearly
wrong.
2017-03-30 22:01:54 +03:00
Lasse Collin 310d19816d liblzma: Make lzma_index_decoder_init() visible to other liblzma funcs.
This is to allow other functions to use it without going
via the public API (lzma_index_decoder()).
2017-03-30 20:03:05 +03:00
Lasse Collin a27920002d liblzma: Add generic support for input seeking (LZMA_SEEK).
Also mention LZMA_SEEK in xz/message.c to silence a warning.
2017-03-30 20:00:09 +03:00
Lasse Collin a0b1dda409 liblzma: Fix lzma_memlimit_set(strm, 0).
The 0 got treated specially in a buggy way and as a result
the function did nothing. The API doc said that 0 was supposed
to return LZMA_PROG_ERROR but it didn't.

Now 0 is treated as if 1 had been specified. This is done because
0 is already used to indicate an error from lzma_memlimit_get()
and lzma_memusage().

In addition, lzma_memlimit_set() no longer checks that the new
limit is at least LZMA_MEMUSAGE_BASE. It's counter-productive
for the Index decoder and was actually needed only by the
auto decoder. Auto decoder has now been modified to check for
LZMA_MEMUSAGE_BASE.
2017-03-30 19:51:14 +03:00
Lasse Collin 84462afaad liblzma: Similar memlimit fix for stream_, alone_, and auto_decoder. 2017-03-30 19:16:55 +03:00
Lasse Collin cbc7401793 liblzma: Fix handling of memlimit == 0 in lzma_index_decoder().
It returned LZMA_PROG_ERROR, which was done to avoid zero as
the limit (because it's a special value elsewhere), but using
LZMA_PROG_ERROR is simply inconvenient and can cause bugs.

The fix/workaround is to treat 0 as if it were 1 byte. It's
effectively the same thing. The only weird consequence is
that then lzma_memlimit_get() will return 1 even when 0 was
specified as the limit.

This fixes a very rare corner case in xz --list where a specific
memory usage limit and a multi-stream file could print the
error message "Internal error (bug)" instead of saying that
the memory usage limit is too low.
2017-03-30 19:10:55 +03:00
Lasse Collin 78ae13bced Update NEWS for 5.2.3. 2016-12-30 13:33:16 +02:00
Lasse Collin 0297863fdb Document --enable-sandbox configure option in INSTALL. 2016-12-26 20:55:52 +02:00
Lasse Collin d4a0462abe liblzma: Avoid multiple definitions of lzma_coder structures.
Only one definition was visible in a translation unit.
It avoided a few casts and temp variables but seems that
this hack doesn't work with link-time optimizations in compilers
as it's not C99/C11 compliant.

Fixes:
http://www.mail-archive.com/xz-devel@tukaani.org/msg00279.html
2016-11-21 20:24:50 +02:00
Lasse Collin a01794c52a Update THANKS. 2016-10-24 18:53:25 +03:00
Lasse Collin df8f446e3a tuklib_cpucores: Add support for sched_getaffinity().
It's available in glibc (GNU/Linux, GNU/kFreeBSD). It's better
than sysconf(_SC_NPROCESSORS_ONLN) because sched_getaffinity()
gives the number of cores available to the process instead of
the total number of cores online.

As a side effect, this commit fixes a bug on GNU/kFreeBSD where
configure would detect the FreeBSD-specific cpuset_getaffinity()
but it wouldn't actually work because on GNU/kFreeBSD it requires
using -lfreebsd-glue when linking. Now the glibc-specific function
will be used instead.

Thanks to Sebastian Andrzej Siewior for the original patch
and testing.
2016-10-24 18:51:36 +03:00
Lasse Collin 446e4318fa xz: Fix copying of timestamps on Windows.
xz used to call utime() on Windows, but its result gets lost
on close(). Using _futime() seems to work.

Thanks to Martok for reporting the bug:
http://www.mail-archive.com/xz-devel@tukaani.org/msg00261.html
2016-06-30 20:27:36 +03:00
Lasse Collin 1b0ac0c53c xz: Silence warnings from -Wlogical-op.
Thanks to Evan Nemerson.
2016-06-16 22:46:02 +03:00
Lasse Collin c83b7a0334 Build: Fix = to += for xz_SOURCES in src/xz/Makefile.am.
Thanks to Christian Kujau.
2016-04-10 20:55:49 +03:00
Lasse Collin ade31a2bfb Build: Bump GNU Gettext version requirement to 0.19.
It silences a few warnings and most people probably have
0.19 even on stable distributions.

Thanks to Christian Kujau.
2016-04-10 20:54:17 +03:00
Lasse Collin ac398c3baf liblzma: Disable external SHA-256 by default.
This is the sane thing to do. The conflict with OpenSSL
on some OSes and especially that the OS-provided versions
can be significantly slower makes it clear that it was
a mistake to have the external SHA-256 support enabled by
default.

Those who want it can now pass --enable-external-sha256 to
configure. INSTALL was updated with notes about OSes where
this can be a bad idea.

The SHA-256 detection code in configure.ac had some bugs that
could lead to a build failure in some situations. These were
fixed, although it doesn't matter that much now that the
external SHA-256 is disabled by default.

MINIX >= 3.2.0 uses NetBSD's libc and thus has SHA256_Init
in libc instead of libutil. Support for the libutil version
was removed.
2016-03-13 20:21:49 +02:00
Lasse Collin 6fd5ecb589 Update THANKS. 2016-03-10 20:27:05 +02:00
Lasse Collin 473ef0dc69 Build: Avoid SHA256_Init on FreeBSD and MINIX 3.
On FreeBSD 10 and older, SHA256_Init from libmd conflicts
with libcrypto from OpenSSL. The OpenSSL version has
different sizeof(SHA256_CTX) and it can cause weird
problems if wrong SHA256_Init gets used.

Looking at the source, MINIX 3 seems to have a similar issue but
I'm not sure. To be safe, I disabled SHA256_Init on MINIX 3 too.

NetBSD has SHA256_Init in libc and they had a similar problem,
but they already fixed it in 2009.

Thanks to Jim Wilcoxson for the bug report that helped
in finding the problem.
2016-03-10 20:26:49 +02:00
Lasse Collin faf302137e tuklib_physmem: Hopefully silence a warning on Windows. 2015-11-08 20:16:10 +02:00
Lasse Collin e52e9151cf Update THANKS. 2015-11-04 23:17:43 +02:00
Lasse Collin 14115f84a3 liblzma: Make Valgrind happier with optimized (gcc -O2) liblzma.
When optimizing, GCC can reorder code so that an uninitialized
value gets used in a comparison, which makes Valgrind unhappy.
It doesn't happen when compiled with -O0, which I tend to use
when running Valgrind.

Thanks to Rich Prohaska. I remember this being mentioned long
ago by someone else but nothing was done back then.
2015-11-04 23:14:00 +02:00
Lasse Collin f4c95ba94b liblzma: Rename lzma_presets.c back to lzma_encoder_presets.c.
It would be too annoying to update other build systems
just because of this.
2015-11-03 20:55:45 +02:00
Lasse Collin c7bc20a6f3 Build: Disable xzdec, lzmadec, and lzmainfo when they cannot be built.
They all need decoder support and if that isn't available,
there's no point trying to build them.
2015-11-03 20:47:07 +02:00
Lasse Collin 5cbca1205d Build: Simplify $enable_{encoders,decoders} usage a bit. 2015-11-03 20:35:19 +02:00
Lasse Collin af13781886 Windows/MSVC: Update config.h. 2015-11-03 20:31:31 +02:00
Lasse Collin 9fa5949330 DOS: Update config.h. 2015-11-03 20:29:58 +02:00
Lasse Collin cb3111e3ed xz: Make xz buildable even when encoders or decoders are disabled.
The patch is quite long but it's mostly about adding new #ifdefs
to omit code when encoders or decoders have been disabled.

This adds two new #defines to config.h: HAVE_ENCODERS and
HAVE_DECODERS.
2015-11-03 20:29:33 +02:00
Lasse Collin 4cc584985c Build: Build LZMA1/2 presets also when only decoder is wanted.
People shouldn't rely on the presets when decoding raw streams,
but xz uses the presets as the starting point for raw decoder
options anyway.

lzma_encocder_presets.c was renamed to lzma_presets.c to
make it clear it's not used solely by the encoder code.
2015-11-03 18:06:40 +02:00
Lasse Collin 23ed1d4148 Build: Fix configure to handle LZMA1 dependency with LZMA2.
Now it gives an error if LZMA1 encoder/decoder is missing
when LZMA2 encoder/decoder was requested. Even better would
be LZMA2 implicitly enabling LZMA1 but it would need more code.
2015-11-03 17:54:48 +02:00
Lasse Collin b0bc3e0385 Build: Don't omit lzma_cputhreads() unless using --disable-threads.
Previously it was omitted if encoders were disabled
with --disable-encoders. It didn't make sense and
it also broke the build.
2015-11-03 17:41:54 +02:00
Lasse Collin c6bf438ab3 liblzma: Fix a build failure related to external SHA-256 support.
If an appropriate header and structure were found by configure,
but a library with a usable SHA-256 functions wasn't, the build
failed.
2015-11-02 18:16:51 +02:00
Lasse Collin e18adc56f2 xz: Always close the file before trying to delete it.
unlink() can return EBUSY in errno for open files on some
operating systems and file systems.
2015-11-02 15:19:10 +02:00
Lasse Collin 282e768a14 Update THANKS. 2015-10-12 21:08:42 +03:00
Lasse Collin 372e402713 Tests: Add tests for the two bugs fixed in index.c. 2015-10-12 21:07:41 +03:00
Lasse Collin 21515d79d7 liblzma: Fix lzma_index_dup() for empty Streams.
Stream Flags and Stream Padding weren't copied from
empty Streams.
2015-10-12 20:45:15 +03:00
Lasse Collin 09f395b6b3 liblzma: Add a note to index.c for those using static analyzers. 2015-10-12 20:31:44 +03:00
Lasse Collin 3bf857edfe liblzma: Fix a memory leak in error path of lzma_index_dup().
lzma_index_dup() calls index_dup_stream() which, in case of
an error, calls index_stream_end() to free memory allocated
by index_stream_init(). However, it illogically didn't
actually free the memory. To make it logical, the tree
handling code was modified a bit in addition to changing
index_stream_end().

Thanks to Evan Nemerson for the bug report.
2015-10-12 20:29:09 +03:00
Lasse Collin 7f05803979 Update NEWS for 5.2.2. 2015-09-29 13:57:28 +03:00
Hauke Henningsen 397fcc0946 Update German translation, mostly wrt orthography
Provide an update of the German translation.
* A lot of compound words were previously written with spaces, while
  German orthography is relatively clear in that the components
  should not be separated.
* When referring to the actual process of (de)compression rather than the
  concept, replace “(De-)Kompression” with “(De-)Komprimierung”.
  Previously, both forms were used in this context and are now used in a
  manner consistent with “Komprimierung” being more likely to refer to
  a process.
* Consistently translate “standard input”/“output”
* Use “Zeichen” instead of false friend “Charakter” for “character”
* Insert commas around relative clauses (as required in German)
* Some other minor corrections
* Capitalize “ß” as “ẞ”
* Consistently start option descriptions in --help with capital letters

Acked-By: Andre Noll <maan@tuebingen.mpg.de>

* Update after msgmerge
2015-08-27 21:28:37 +03:00
Lasse Collin cbc9e39bae Build: Minor Cygwin cleanup.
Some tests used "cygwin*" and some used "cygwin". I changed
them all to use "cygwin". Shouldn't affect anything in practice.
2015-08-11 13:23:04 +03:00
Lasse Collin bcacd8ce7a Build: Support building of MSYS2 binaries. 2015-08-11 13:21:52 +03:00
Lasse Collin 0275a5398c Windows: Define DLL_EXPORT when building liblzma.dll with MSVC.
src/liblzma/common/common.h uses it to set __declspec(dllexport)
for the API symbols.

Thanks to Adam Walling.
2015-08-09 21:06:26 +03:00
Lasse Collin a74525cf9b Windows: Omit unneeded header files from MSVC project files. 2015-08-09 21:02:20 +03:00
Lasse Collin fbbb295a91 liblzma: A MSVC-specific hack isn't needed with MSVC 2013 and newer. 2015-07-12 20:48:19 +03:00
Lasse Collin 713dbe5c23 Update THANKS. 2015-06-19 20:38:55 +03:00
Lasse Collin 3a5d755d05 Windows: Update the docs. 2015-06-19 20:21:30 +03:00
Lasse Collin b0798c6aa6 Windows: Add MSVC project files for building liblzma.
Thanks to Adam Walling for creating these files.
2015-06-19 17:25:31 +03:00
Andre Noll 9b02a4ffda Fix typo in German translation.
As pointed out by Robert Pollak, there's a typo in the German
translation of the compression preset option (-0 ... -9) help text.
"The compressor" translates to "der Komprimierer", and the genitive
form is "des Komprimierers". The old word makes no sense at all.
2015-06-10 21:01:09 +03:00
Lasse Collin c7f4041f6b Tests: Fix a memory leak in test_bcj_exact_size.
Thanks to Cristian Rodríguez.
2015-05-13 20:57:55 +03:00
Lasse Collin 17b29d4f0a Fix NEWS about threading in 5.2.0.
Thanks to Andy Hochhaus.
2015-05-12 18:08:24 +03:00
Lasse Collin 49c26920d6 xz: Document that threaded decompression hasn't been implemented yet. 2015-05-11 21:26:16 +03:00
Lasse Collin 5b2458cb24 Update THANKS. 2015-04-20 20:20:38 +03:00
Lasse Collin 6bd0349c58 Revert "xz: Use pipe2() if available."
This reverts commit 7a11c4a8e5.
It is a problem when libc has pipe2() but the kernel is too
old to have pipe2() and thus pipe2() fails. In xz it's pointless
to have a fallback for non-functioning pipe2(); it's better to
avoid pipe2() completely.

Thanks to Michael Fox for the bug report.
2015-04-20 20:17:48 +03:00
Lasse Collin fc0df0f8db xz: Fix the Capsicum rights on user_abort_pipe. 2015-04-01 14:45:25 +03:00
Lasse Collin 57393615b3 Update THANKS. 2015-03-31 22:20:11 +03:00
Lasse Collin 1238381143 xz: Add support for sandboxing with Capsicum.
The sandboxing is used conditionally as described in main.c.
This isn't optimal but it was much easier to implement than
a full sandboxing solution and it still covers the most common
use cases where xz is writing to standard output. This should
have practically no effect on performance even with small files
as fork() isn't needed.

C and locale libraries can open files as needed. This has been
fine in the past, but it's a problem with things like Capsicum.
io_sandbox_enter() tries to ensure that various locale-related
files have been loaded before cap_enter() is called, but it's
possible that there are other similar problems which haven't
been seen yet.

Currently Capsicum is available on FreeBSD 10 and later
and there is a port to Linux too.

Thanks to Loganaden Velvindron for help.
2015-03-31 22:19:34 +03:00
Lasse Collin 29a087fb5a Fix bugs and otherwise improve ax_check_capsicum.m4.
AU_ALIAS was removed because the new version is incompatible
with the old version.

It no longer checks for <sys/capability.h> separately.
It's enough to test for it as part of AC_CHECK_DECL.
The defines HAVE_CAPSICUM_SYS_CAPSICUM_H and
HAVE_CAPSICUM_SYS_CAPABILITY_H were removed as unneeded.
HAVE_SYS_CAPSICUM_H from AC_CHECK_HEADERS is enough.

It no longer does a useless search for the Capsicum library
if the header wasn't found.

Fixed a bug in ACTION-IF-FOUND (the first argument). Specifying
the argument omitted the default action but the given action
wasn't used instead.

AC_DEFINE([HAVE_CAPSICUM]) is now always called when Capsicum
support is found. Previously it was part of the default
ACTION-IF-FOUND which a custom action would override. Now
the default action only prepends ${CAPSICUM_LIB} to LIBS.

The documentation was updated.

Since there as no serial number, "#serial 2" was added.
2015-03-31 21:12:30 +03:00
Lasse Collin 6e845c6a3e Add m4/ax_check_capsicum.m4 for detecting Capsicum support.
The file was loaded from this web page:
https://github.com/google/capsicum-test/blob/dev/autoconf/m4/ax_check_capsicum.m4

Thanks to Loganaden Velvindron for pointing it out for me.
2015-03-31 19:20:24 +03:00
Lasse Collin 3717885f9e Bump version to 5.3.0alpha and soname to 5.3.99.
The idea of 99 is that it looks a bit weird in this context.
For new features there's no API/ABI stability in devel versions.
2015-03-30 22:44:02 +03:00
Lasse Collin eccd8155e1 Update THANKS. 2015-03-29 22:14:47 +03:00
Lasse Collin 25263fd9e7 Fix the detection of installed RAM on QNX.
The earlier version compiled but didn't actually work
since sysconf(_SC_PHYS_PAGES) always fails (or so I was told).

Thanks to Ole André Vadla Ravnås for the patch and testing.
2015-03-29 22:13:48 +03:00
Lasse Collin 4c544d2410 Fix CPU core count detection on QNX.
It tried to use sysctl() on QNX but
  - it broke the build because sysctl() needs -lsocket on QNX;
  - sysctl() doesn't work for detecting the core count on QNX
    even if it compiled.

sysconf() works. An alternative would have been to use
QNX-specific SYSPAGE_ENTRY(num_cpu) from <sys/syspage.h>.

Thanks to Ole André Vadla Ravnås.
2015-03-27 22:39:07 +02:00
Lasse Collin e0ea6737b0 xz: size_t/uint32_t cleanup in options.c. 2015-03-07 22:05:57 +02:00
Lasse Collin 8bcca29a65 xz: Fix a comment and silence a warning in message.c. 2015-03-07 22:04:23 +02:00
Lasse Collin f243f5f44c liblzma: Silence more uint32_t vs. size_t warnings. 2015-03-07 22:01:00 +02:00
Lasse Collin 7f0a4c50f4 xz: Make arg_count an unsigned int to silence a warning.
Actually the value of arg_count cannot exceed INT_MAX
but it's nicer as an unsigned int.
2015-03-07 19:54:00 +02:00
Lasse Collin f6ec468015 liblzma: Fix a warning in index.c. 2015-03-07 19:33:17 +02:00
Lasse Collin a24518971c Build: Fix a CR+LF problem when running autoreconf -fi on OS/2. 2015-02-26 20:46:14 +02:00
Lasse Collin dec11497a7 Bump version and soname for 5.2.1. 2015-02-26 16:53:44 +02:00
Lasse Collin 29e39c7997 Update NEWS for 5.2.1. 2015-02-26 13:01:09 +02:00
Lasse Collin 7a11c4a8e5 xz: Use pipe2() if available. 2015-02-22 19:38:48 +02:00
Lasse Collin 117d962685 liblzma: Fix a compression-ratio regression in LZMA1/2 in fast mode.
The bug was added in the commit
f48fce093b and thus
affected 5.1.4beta and 5.2.0. Luckily the bug cannot
cause data corruption or other nasty things.
2015-02-21 23:40:26 +02:00
Lasse Collin ae984e31c1 xz: Fix the fcntl() usage when creating a pipe for the self-pipe trick.
Now it reads the old flags instead of blindly setting O_NONBLOCK.
The old code may have worked correctly, but this is better.
2015-02-21 23:00:19 +02:00
Lasse Collin 2205bb5853 Update THANKS. 2015-02-10 15:29:34 +02:00
Lasse Collin d935b0cdf3 tuklib_cpucores: Use cpuset_getaffinity() on FreeBSD if available.
In FreeBSD, cpuset_getaffinity() is the preferred way to get
the number of available cores.

Thanks to Rui Paulo for the patch. I edited it slightly, but
hopefully I didn't break anything.
2015-02-10 15:28:30 +02:00
Lasse Collin eb61bc58c2 xzdiff: Make the mktemp usage compatible with FreeBSD's mktemp.
Thanks to Rui Paulo for the fix.
2015-02-09 22:08:37 +02:00
Lasse Collin b9a5b6b7a2 Add a few casts to tuklib_integer.h to silence possible warnings.
I heard that Visual Studio 2013 gave warnings without the casts.

Thanks to Gabi Davar.
2015-02-03 21:45:53 +02:00
Lasse Collin c45757135f liblzma: Set LZMA_MEMCMPLEN_EXTRA depending on the compare method. 2015-01-26 21:24:39 +02:00
Lasse Collin 3c500174ed Update THANKS. 2015-01-26 20:40:16 +02:00
Lasse Collin fec88d41e6 liblzma: Silence harmless Valgrind errors.
Thanks to Torsten Rupp for reporting this. I had
forgotten to run Valgrind before the 5.2.0 release.
2015-01-26 20:39:28 +02:00
Lasse Collin a9b45badfe xz: Fix comments. 2015-01-09 21:50:19 +02:00
Lasse Collin 541aee6dd4 Update THANKS. 2015-01-09 21:35:06 +02:00
Lasse Collin 4170edc914 xz: Don't fail if stdout doesn't support O_NONBLOCK.
This is similar to the case with stdin.

Thanks to Brad Smith for the bug report and testing
on OpenBSD.
2015-01-09 21:34:06 +02:00
Lasse Collin 04bbc0c284 xz: Fix a memory leak in DOS-specific code. 2015-01-07 19:18:20 +02:00
Lasse Collin f0f1f6c723 xz: Don't fail if stdin doesn't support O_NONBLOCK.
It's a problem at least on OpenBSD which doesn't support
O_NONBLOCK on e.g. /dev/null. I'm not surprised if it's
a problem on other OSes too since this behavior is allowed
in POSIX-1.2008.

The code relying on this behavior was committed in June 2013
and included in 5.1.3alpha released on 2013-10-26. Clearly
the development releases only get limited testing.
2015-01-07 19:08:06 +02:00
Lasse Collin d2d484647d Tests: Don't hide unexpected error messages in test_files.sh.
Hiding them makes no sense since normally there's no error
when testing the "good" files. With "bad" files errors are
expected and then it makes sense to keep the messages hidden.
2015-01-06 20:30:15 +02:00
Lasse Collin aae6a6aeda Update Solaris notes in INSTALL.
Mention the possible "make check" failure on Solaris in the
Solaris-specific section of INSTALL. It was already in
section 4.5 but it is better mention it in the OS-specific
section too.
2014-12-30 11:17:16 +02:00
Lasse Collin 7815112153 Build: POSIX shell isn't required if scripts are disabled. 2014-12-26 12:00:05 +02:00
Lasse Collin a0cd05ee71 DOS: Update Makefile. 2014-12-21 20:48:37 +02:00
Lasse Collin b85ee0905e Windows: Fix bin_i486 to bin_i686 in build.bash. 2014-12-21 19:50:38 +02:00
Lasse Collin cbafa71091 Docs: Use lzma_cputhreads() in 04_compress_easy_mt.c. 2014-12-21 18:58:44 +02:00
Lasse Collin 8dbb57238d Docs: Update docs/examples/00_README.txt. 2014-12-21 18:56:44 +02:00
Lasse Collin 6060f7dc76 Bump version and soname for 5.2.0.
I know that soname != app version, but I skip AGE=1
in -version-info to make the soname match the liblzma
version anyway. It doesn't hurt anything as long as
it doesn't conflict with library versioning rules.
2014-12-21 18:11:17 +02:00
Lasse Collin 3e8bd1d15e Avoid variable-length arrays in the debug programs. 2014-12-21 18:05:03 +02:00
Lasse Collin 72f7307cfd Build: Include 04_compress_easy_mt.c in the tarball. 2014-12-21 18:01:45 +02:00
Lasse Collin 2cb82ff21c Fix build when --disable-threads is used. 2014-12-21 18:00:38 +02:00
Adrien Nader 9b9e3536e4 po/fr: improve wording for help for --lzma1/--lzma2. 2014-12-21 18:00:09 +02:00
Adrien Nader a8b6b569e7 po/fr: missing line in translation of --extreme. 2014-12-21 18:00:09 +02:00
Lasse Collin f168a6fd1a Update NEWS for 5.2.0. 2014-12-21 14:32:33 +02:00
Lasse Collin cec2ee863b Update NEWS for 5.0.8. 2014-12-21 14:32:22 +02:00
Lasse Collin 42e97a3264 xz: Fix a comment. 2014-12-21 14:07:54 +02:00
Lasse Collin 29b95d5d66 Update INSTALL about the dependencies of the scripts. 2014-12-20 20:43:14 +02:00
Lasse Collin 3af91040bb Windows: Update build instructions. 2014-12-20 20:42:33 +02:00
Lasse Collin 0152f72bf6 Windows: Update the build script and README-Windows.txt.
The 32-bit build is now for i686 or newer because the
prebuilt MinGW-w64 toolchains include i686 code in the
executables even if one uses -march=i486.

The build script builds 32-bit SSE2 enabled version too.
Run-time detection of SSE2 support would be nice (on any OS)
but it's not implemented in XZ Utils yet.
2014-12-20 20:41:48 +02:00
Lasse Collin 4a1f6133ee Windows: Define TUKLIB_SYMBOL_PREFIX in config.h.
It is to keep all symbols in the lzma_ namespace.
2014-12-19 15:51:50 +02:00
Lasse Collin 7f7d093de7 xz: Update the man page about --threads. 2014-12-16 21:00:09 +02:00
Lasse Collin 009823448b xz: Update the man page about --block-size. 2014-12-16 20:57:43 +02:00
Adrien Nader 7dddfbeb49 po/fr: several more translation updates: reword and handle --ignore-check. 2014-12-12 19:16:10 +02:00
Adrien Nader 6eca5be40e po/fr: yet another place where my email address had to be updated. 2014-12-12 19:16:10 +02:00
Adrien Nader d1003673e9 po/fr: fix several typos that have been around since the beginning. 2014-12-12 19:16:10 +02:00
Adrien Nader 4c5aa911a0 po/fr: last batch of new translations for now.
Four new error messages.
2014-12-12 19:16:10 +02:00
Adrien Nader 3e3099e36d po/fr: translations for --threads, --block-size and --block-list. 2014-12-12 19:16:10 +02:00
Adrien Nader e7d96a5933 po/fr: remove fuzzy marker for error messages that will be kept in English.
The following is a copy of a comment inside fr.po:

Note from translator on "file status flags".
The following entry is kept un-translated on purpose. It is difficult to
translate and should only happen in exceptional circumstances which means
that translating would:
- lose some of the meaning
- make it more difficult to look up in search engines; it might happen one
in
a million times, if we dilute the error message in 20 languages, it will be
almost impossible to find an explanation and support for the error.
2014-12-12 19:16:10 +02:00
Adrien Nader 46cbb9033a po/fr: several minor updates and better wording.
Meaning doesn't change at all: it's only for better wording and/or
formatting of a few strings.
2014-12-12 19:16:10 +02:00
Adrien Nader 7ce49d444f po/fr: update my email address and copyright years. 2014-12-12 19:16:09 +02:00
Adrien Nader 214c553ebc fr.po: commit file after only "update-po" so actual is readable. 2014-12-12 19:16:09 +02:00
Lasse Collin 1190c641af liblzma: Document how lzma_mt.block_size affects memory usage. 2014-12-02 20:04:07 +02:00
Lasse Collin e4fc1d2f95 Update INSTALL about a "make check" failure in test_scripts.sh. 2014-11-28 20:07:18 +02:00
Lasse Collin 34f9e40a0a Remove LZMA_UNSTABLE macro. 2014-11-26 20:12:27 +02:00
Lasse Collin 6d9c0ce9f2 liblzma: Update lzma_stream_encoder_mt() API docs. 2014-11-26 20:10:33 +02:00
Lasse Collin 2301f3f05d liblzma: Verify the filter chain in threaded encoder initialization.
This way an invalid filter chain is detected at the Stream
encoder initialization instead of delaying it to the first
call to lzma_code() which triggers the initialization of
the actual filter encoder(s).
2014-11-25 12:32:05 +02:00
Lasse Collin 107a263d5b Build: Update m4/ax_pthread.m4 from Autoconf Archive. 2014-11-17 19:11:49 +02:00
Lasse Collin b13a781833 Build: Replace obsolete AC_HELP_STRING with AS_HELP_STRING. 2014-11-17 18:52:21 +02:00
Lasse Collin 542cac122e Build: Fix Autoconf warnings about escaped backquotes.
Thanks to Daniel Richard G. for pointing out that it's
good to sometimes run autoreconf -fi with -Wall.
2014-11-17 18:43:19 +02:00
Lasse Collin 7b03a15cea xzdiff: Use mkdir if mktemp isn't available. 2014-11-10 18:54:40 +02:00
Lasse Collin f8c13e5e36 xzdiff: Create a temporary directory to hold a temporary file.
This avoids the possibility of "File name too long" when
creating a temp file when the input file name is very long.

This also means that other users on the system can no longer
see the input file names in /tmp (or whatever $TMPDIR is)
since the temporary directory will have a generic name. This
usually doesn't matter since on many systems one can see
the arguments given to all processes anyway.

The number X chars to mktemp where increased from 6 to 10.

Note that with some shells temp files or dirs won't be used at all.
2014-11-10 18:45:01 +02:00
Lasse Collin 7716dcf9df liblzma: Fix lzma_mt.preset in lzma_stream_encoder_mt_memusage().
It read the filter chain from a wrong variable. This is a similar
bug that was fixed in 9494fb6d0f.
2014-11-10 15:38:47 +02:00
Lasse Collin 230fa4a605 Update THANKS. 2014-11-10 14:49:55 +02:00
Lasse Collin 4e4ae08bc7 Update .gitignore files. 2014-10-29 21:28:25 +02:00
Lasse Collin c923b140b2 Build: Prepare to support Automake's subdir-objects.
Due to a bug in Automake, subdir-objects won't be enabled
for now.

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17354

Thanks to Daniel Richard G. for the original patches.
2014-10-29 21:15:35 +02:00
Lasse Collin 08c2aa16be Translations: Update the Italian translation.
Thanks to Milo Casagrande.
2014-10-24 20:09:29 +03:00
Lasse Collin 2f9f61aa83 Translations: Update the Polish translation.
Thanks to Jakub Bogusz.
2014-10-18 18:51:45 +03:00
Andre Noll 4f9d233f67 l10n: de.po: Change translator email address.
Although the old address is still working, the new one should
be preferred. So this commit changes all three places in de.po
accordingly.

Signed-off-by: Andre Noll <maan@tuebingen.mpg.de>
2014-10-14 22:06:10 +03:00
Andre Noll 00502b2bed l10n: de.po: Update German translation
Signed-off-by: Andre Noll <maan@systemlinux.org>
2014-10-14 22:06:10 +03:00
Andre Noll 706b049675 l10n: de.po: Fix typo: Schießen -> Schließen.
That's a funny one since "schießen" means to shoot :)

Signed-off-by: Andre Noll <maan@systemlinux.org>
2014-10-14 22:06:09 +03:00
Lasse Collin 7c32e6a935 Update THANKS. 2014-10-09 19:42:26 +03:00
Lasse Collin 076258cc45 Add support for AmigaOS/AROS to tuklib_physmem().
Thanks to Fredrik Wikstrom.
2014-10-09 19:41:51 +03:00
Lasse Collin efa7b0a210 xzgrep: Avoid passing both -q and -l to grep.
The behavior of grep -ql varies:
  - GNU grep behaves like grep -q.
  - OpenBSD grep behaves like grep -l.

POSIX doesn't make it 100 % clear what behavior is expected.
Anyway, using both -q and -l at the same time makes no sense
so both options simply should never be used at the same time.

Thanks to Christian Weisgerber.
2014-10-09 18:42:14 +03:00
Trần Ngọc Quân 9c5f76098c l10n: vi.po: Update Vietnamese translation
Signed-off-by: Trần Ngọc Quân <vnwildman@gmail.com>
2014-10-04 08:33:39 +07:00
Lasse Collin c4911f2db3 Build: Detect supported compiler warning flags better.
Clang and nowadays also GCC accept any -Wfoobar option
but then may give a warning that an unknown warning option
was specified. To avoid adding unsupported warning options,
the options are now tested with -Werror.

Thanks to Charles Diza.
2014-09-25 18:38:48 +03:00
Lasse Collin 76e75522ed Update NEWS for 5.0.7. 2014-09-20 21:01:21 +03:00
Lasse Collin d62028b4c1 liblzma: Fix a portability problem in Makefile.am.
POSIX supports $< only in inference rules (suffix rules).
Using it elsewhere is a GNU make extension and doesn't
work e.g. with OpenBSD make.

Thanks to Christian Weisgerber for the patch.
2014-09-20 19:42:56 +03:00
Lasse Collin c35de31d42 Bump the version number to 5.1.4beta. 2014-09-14 21:54:09 +03:00
Lasse Collin e9e097e22c Update NEWS for 5.0.6 and 5.1.4beta. 2014-09-14 21:50:13 +03:00
Lasse Collin 642f856bb8 Update TODO. 2014-09-14 21:02:41 +03:00
Lasse Collin 6b5e3b9eff xz: Add --ignore-check. 2014-08-05 22:32:36 +03:00
Lasse Collin 9adbc2ff37 liblzma: Add support for LZMA_IGNORE_CHECK. 2014-08-05 22:15:07 +03:00
Lasse Collin 0e0f34b8e4 liblzma: Add support for lzma_block.ignore_check.
Note that this slightly changes how lzma_block_header_decode()
has been documented. Earlier it said that the .version is set
to the lowest required value, but now it says that the .version
field is kept unchanged if possible. In practice this doesn't
affect any old code, because before this commit the only
possible .version was 0.
2014-08-05 22:03:30 +03:00
Lasse Collin 71e1437ab5 liblzma: Use lzma_memcmplen() in the BT3 match finder.
I had missed this when writing the commit
5db75054e9.

Thanks to Jun I Jin.
2014-08-04 19:25:58 +03:00
Lasse Collin 41dc9ea06e Update THANKS. 2014-08-04 00:25:44 +03:00
Lasse Collin 5dcffdbcc2 liblzma: SHA-256: Optimize the Maj macro slightly.
The Maj macro is used where multiple things are added
together, so making Maj a sum of two expressions allows
some extra freedom for the compiler to schedule the
instructions.

I learned this trick from
<http://www.hackersdelight.org/corres.txt>.
2014-08-03 21:32:25 +03:00
Lasse Collin a9477d1e0c liblzma: SHA-256: Optimize the way rotations are done.
This looks weird because the rotations become sequential,
but it helps quite a bit on both 32-bit and 64-bit x86:

  - It requires fewer instructions on two-operand
    instruction sets like x86.

  - It requires one register less which matters especially
    on 32-bit x86.

I hope this doesn't hurt other archs.

I didn't invent this idea myself, but I don't remember where
I saw it first.
2014-08-03 21:08:12 +03:00
Lasse Collin 5a76c7c8ee liblzma: SHA-256: Remove the GCC #pragma that became unneeded.
The unrolling in the previous commit should avoid the
situation where a compiler may think that an uninitialized
variable might be accessed.
2014-08-03 20:38:13 +03:00
Lasse Collin 9a096f8e57 liblzma: SHA-256: Unroll a little more.
This way a branch isn't needed for each operation
to choose between blk0 and blk2, and still the code
doesn't grow as much as it would with full unrolling.
2014-08-03 20:33:38 +03:00
Lasse Collin bc7650d87b liblzma: SHA-256: Do the byteswapping without a temporary buffer. 2014-08-03 19:56:43 +03:00
Lasse Collin 544aaa3d13 liblzma: Use lzma_memcmplen() in normal mode of LZMA.
Two locations were not changed yet because the simplest change
assumes that the initial "len" may be greater than "limit".
2014-07-25 22:38:28 +03:00
Lasse Collin f48fce093b liblzma: Simplify LZMA fast mode code by using memcmp(). 2014-07-25 22:30:38 +03:00
Lasse Collin 6bf5308e34 liblzma: Use lzma_memcmplen() in fast mode of LZMA. 2014-07-25 22:29:49 +03:00
Lasse Collin 353212137e Update THANKS. 2014-07-25 21:16:23 +03:00
Lasse Collin 5db75054e9 liblzma: Use lzma_memcmplen() in the match finders.
This doesn't change the match finder output.
2014-07-25 21:15:07 +03:00
Lasse Collin e1c8f1d01f liblzma: Add lzma_memcmplen() for fast memory comparison.
This commit just adds the function. Its uses will be in
separate commits.

This hasn't been tested much yet and it's perhaps a bit early
to commit it but if there are bugs they should get found quite
quickly.

Thanks to Jun I Jin from Intel for help and for pointing out
that string comparison needs to be optimized in liblzma.
2014-07-25 20:57:20 +03:00
Lasse Collin 765735cf52 Update THANKS. 2014-07-12 21:10:09 +03:00
Lasse Collin 59da01785e Translations: Add Vietnamese translation.
Thanks to Trần Ngọc Quân.
2014-07-12 20:06:08 +03:00
Lasse Collin 17215f751c xz: Update the help message of a few options.
Updated: --threads, --block-size, and --block-list
Added: --flush-timeout
2014-06-29 20:54:14 +03:00
Lasse Collin 96864a6ddf xz: Use lzma_cputhreads() instead of own copy of tuklib_cpucores(). 2014-06-18 22:07:06 +03:00
Lasse Collin a115cc3748 liblzma: Add lzma_cputhreads(). 2014-06-18 22:04:24 +03:00
Lasse Collin 3ce3e79769 xz: Check for filter chain compatibility for --flush-timeout.
This avoids LZMA_PROG_ERROR from lzma_code() with filter chains
that don't support LZMA_SYNC_FLUSH.
2014-06-18 19:11:52 +03:00
Lasse Collin 381ac14ed7 xzgrep: List xzgrep_expected_output in tests/Makefile.am. 2014-06-13 19:21:54 +03:00
Lasse Collin 4244b65b06 xzgrep: Improve the test script.
Now it should be close to the functionality of the original
version by Pavel Raiskup.
2014-06-13 18:58:22 +03:00
Lasse Collin 1e60f2c0a0 xzgrep: Add a test for the previous fix.
This is a simplified version of Pavel Raiskup's
original patch.
2014-06-11 21:03:25 +03:00
Lasse Collin ceca379017 xzgrep: exit 0 when at least one file matches.
Mimic the original grep behavior and return exit_success when
at least one xz compressed file matches given pattern.

Original bugreport:
https://bugzilla.redhat.com/show_bug.cgi?id=1108085

Thanks to Pavel Raiskup for the patch.
2014-06-11 20:43:28 +03:00
Lasse Collin 8c19216bac xz: Force single-threaded mode when --flush-timeout is used. 2014-06-09 21:21:24 +03:00
Lasse Collin 87f1a24810 Update THANKS. 2014-05-25 22:05:39 +03:00
Lasse Collin da1718f266 liblzma: Use lzma_alloc_zero() in LZ encoder initialization.
This avoids a memzero() call for a newly-allocated memory,
which can be expensive when encoding small streams with
an over-sized dictionary.

To avoid using lzma_alloc_zero() for memory that doesn't
need to be zeroed, lzma_mf.son is now allocated separately,
which requires handling it separately in normalize() too.

Thanks to Vincenzo Innocente for reporting the problem.
2014-05-25 21:45:56 +03:00
Lasse Collin 28af24e9cf liblzma: Add the internal function lzma_alloc_zero(). 2014-05-25 19:25:57 +03:00
Lasse Collin ed9ac85822 xz: Fix uint64_t vs. size_t which broke 32-bit build.
Thanks to Christian Hesse.
2014-05-08 18:03:09 +03:00
Lasse Collin d716acdae3 Docs: Update comments to refer to lzma/lzma12.h in example programs. 2014-05-04 11:09:11 +03:00
Lasse Collin 4d5b7b3fda liblzma: Rename the private API header lzma/lzma.h to lzma/lzma12.h.
It can be confusing that two header files have the same name.
The public API file is still lzma.h.
2014-05-04 11:07:17 +03:00
Lasse Collin 1555a9c566 Build: Fix the combination of --disable-xzdec --enable-lzmadec.
In this case "make install" could fail if the man page directory
didn't already exist at the destination. If it did exist, a
dangling symlink was created there. Now the link is omitted
instead. This isn't the best fix but it's better than the old
behavior.
2014-04-25 17:53:42 +03:00
Lasse Collin 56056571df Build: Add --disable-doc to configure. 2014-04-25 17:44:26 +03:00
Lasse Collin 6de61d8721 Update INSTALL.
Add a note about failing "make check". The source of
the problem should be fixed in libtool (if it really is
a libtool bug and not mine) but I'm unable to spend time
on that for now. Thanks to Nelson H. F. Beebe for reporting
the issue.

Add a note about a possible need to run "ldconfig" after
"make install".
2014-04-24 18:06:24 +03:00
Lasse Collin 54df428799 xz: Rename a variable to avoid a namespace collision on Solaris.
I don't know the details but I have an impression that there's
no problem in practice if using GCC since people have built xz
with GCC (without patching xz), but renaming the variable cannot
hurt either.

Thanks to Mark Ashley.
2014-04-09 17:26:10 +03:00
Lasse Collin 5876ca27da Docs: Add example program for threaded encoding.
I didn't add -DLZMA_UNSTABLE to Makefile so one has to
specify it manually as long as LZMA_UNSTABLE is needed.
2014-01-29 20:19:41 +02:00
Lasse Collin 9494fb6d0f liblzma: Fix lzma_mt.preset not working with lzma_stream_encoder_mt().
It read the filter chain from a wrong variable.
2014-01-29 20:13:51 +02:00
Lasse Collin 673a4cb53d liblzma: Fix typo in a comment. 2014-01-20 11:20:40 +02:00
Lasse Collin ad96a871a1 Windows: Add config.h for building liblzma with MSVC 2013.
This is for building liblzma. Building xz tool too requires
a little more work. Maybe it will be supported, but for most
MSVC users it's enough to be able to build liblzma.

C99 support in MSVC 2013 is almost usable which is a big
improvement over earlier versions. It's "almost" because
there's a dumb bug that breaks mixed declarations after
an "if" statements unless the "if" statement uses braces:

https://connect.microsoft.com/VisualStudio/feedback/details/808650/visual-studio-2013-c99-compiler-bug
https://connect.microsoft.com/VisualStudio/feedback/details/808472/c99-support-of-mixed-declarations-and-statements-fails-with-certain-types-and-constructs

Hopefully it will get fixed. Then liblzma should be
compilable with MSVC 2013 without patching.
2014-01-12 19:38:43 +02:00
Lasse Collin 3d5c090872 xz: Fix a comment. 2014-01-12 17:41:14 +02:00
Lasse Collin 69fd4e1c93 Windows: Add MSVC defines for inline and restrict keywords. 2014-01-12 17:04:33 +02:00
Lasse Collin a19d9e8575 liblzma: Avoid C99 compound literal arrays.
MSVC 2013 doesn't like them. Maybe they aren't so good
for readability either since many aren't used to them.
2014-01-12 16:44:52 +02:00
Lasse Collin e28528f1c8 liblzma: Remove a useless C99ism from sha256.c.
Unsurprisingly it makes no difference in compiled output.
2014-01-12 12:50:30 +02:00
Lasse Collin 5ad1effc45 xz: Fix use of wrong variable.
Since the only call to suffix_set() uses optarg
as the argument, fixing this bug doesn't change
the behavior of the program.
2014-01-12 12:17:08 +02:00
Lasse Collin 3e62c68d75 Fix typos in comments. 2014-01-12 12:11:36 +02:00
Lasse Collin e90ea601fb Update THANKS. 2013-11-26 18:20:16 +02:00
Lasse Collin b22e94d8d1 liblzma: Document the need for block->check for lzma_block_header_decode().
Thanks to Tomer Chachamu.
2013-11-26 18:20:09 +02:00
Lasse Collin d1cd8b1cb8 xz: Update the man page about --block-size and --block-list. 2013-11-12 16:38:57 +02:00
Lasse Collin 76be7c612e Update THANKS. 2013-11-12 16:30:53 +02:00
Lasse Collin dd750acbe2 xz: Make --block-list and --block-size work together in single-threaded.
Previously, --block-list and --block-size only worked together
in threaded mode. Boundaries are specified by --block-list, but
--block-size specifies the maximum size for a Block. Now this
works in single-threaded mode too.

Thanks to James M Leddy for the original patch.
2013-11-12 16:29:48 +02:00
Lasse Collin ae222fe980 Bump the version number to 5.1.3alpha. 2013-10-26 13:26:14 +03:00
Lasse Collin 2193837a6a Update NEWS for 5.1.3alpha. 2013-10-26 13:25:02 +03:00
Lasse Collin ed48e75e27 Update TODO. 2013-10-26 12:47:04 +03:00
Lasse Collin 841da0352d xz: Document behavior of --block-list with threads.
This needs to be updated before 5.2.0.
2013-10-25 22:41:28 +03:00
Lasse Collin 56feb8665b xz: Document --flush-timeout=TIMEOUT on the man page. 2013-10-22 20:03:12 +03:00
Lasse Collin ba413da1d5 xz: Take advantage of LZMA_FULL_BARRIER with --block-list.
Now if --block-list is used in threaded mode, the encoder
won't need to flush at each Block boundary specified via
--block-list. This improves performance a lot, making
threading helpful with --block-list.

The flush timer was reset after LZMA_FULL_FLUSH but since
LZMA_FULL_BARRIER doesn't flush, resetting the timer is
no longer done.
2013-10-22 19:51:55 +03:00
Lasse Collin 0cd45fc2bc liblzma: Support LZMA_FULL_FLUSH and _BARRIER in threaded encoder.
Now --block-list=SIZES works with in the threaded mode too,
although the performance is still bad due to the use of
LZMA_FULL_FLUSH instead of the new LZMA_FULL_BARRIER.
2013-10-02 20:05:23 +03:00
Lasse Collin 97bb38712f liblzma: Add LZMA_FULL_BARRIER support to single-threaded encoder.
In the single-threaded encoder LZMA_FULL_BARRIER is simply
an alias for LZMA_FULL_FLUSH.
2013-10-02 12:55:11 +03:00
Lasse Collin fef0c6b410 liblzma: Add block_buffer_encoder.h into Makefile.inc.
This should have been in b465da5988.
2013-09-17 11:57:51 +03:00
Lasse Collin 8083e03291 xz: Add a missing test for TUKLIB_DOSLIKE. 2013-09-17 11:55:38 +03:00
Lasse Collin 6b44b4a775 Add native threading support on Windows.
Now liblzma only uses "mythread" functions and types
which are defined in mythread.h matching the desired
threading method.

Before Windows Vista, there is no direct equivalent to
pthread condition variables. Since this package doesn't
use pthread_cond_broadcast(), pre-Vista threading can
still be kept quite simple. The pre-Vista code doesn't
use anything that wasn't already available in Windows 95,
so the binaries should run even on Windows 95 if someone
happens to care.
2013-09-17 11:52:28 +03:00
Lasse Collin ae0ab74a88 Build: Remove a comment about Automake 1.10 from configure.ac.
The previous commit supports silent rules and that requires
Automake 1.11.
2013-09-11 14:40:35 +03:00
Lasse Collin 72975df6c8 Build: Create liblzma.pc in a src/liblzma/Makefile.am.
Previously it was done in configure, but doing that goes
against the Autoconf manual. Autoconf requires that it is
possible to override e.g. prefix after running configure
and that doesn't work correctly if liblzma.pc is created
by configure.

A potential downside of this change is that now e.g.
libdir in liblzma.pc is a standalone string instead of
being defined via ${prefix}, so if one overrides prefix
when running pkg-config the libdir won't get the new value.
I don't know if this matters in practice.

Thanks to Vincent Torri.
2013-09-09 20:37:03 +03:00
Lasse Collin 1c2b6e7e83 Fix the previous commit which broke the build.
Apparently I didn't even compile-test the previous commit.

Thanks to Christian Hesse.
2013-08-04 15:24:09 +03:00
Lasse Collin 124eb69c78 Windows: Add Windows support to tuklib_cpucores().
It is used for Cygwin too. I'm not sure if that is
a good or bad idea.

Thanks to Vincent Torri.
2013-08-03 13:52:58 +03:00
Anders F Bjorklund eada8a875c macosx: separate liblzma package 2013-08-03 13:15:32 +03:00
Anders F Bjorklund be0100d01c macosx: set minimum to leopard 2013-08-03 13:15:32 +03:00
Anders F Bjorklund 416729e2d7 move configurables into variables 2013-08-03 13:15:32 +03:00
Lasse Collin 16581080e5 Update THANKS. 2013-07-15 14:08:41 +03:00
Lasse Collin 3e2b198ba3 Build: Fix the detection of missing CRC32.
Thanks to Vincent Torri.
2013-07-15 14:08:02 +03:00
Lasse Collin dee6ad3d59 xz: Add preliminary support for --flush-timeout=TIMEOUT.
When --flush-timeout=TIMEOUT is used, xz will use
LZMA_SYNC_FLUSH if read() would block and at least
TIMEOUT milliseconds has elapsed since the previous flush.

This can be useful in realtime-like use cases where the
data is simultanously decompressed by another process
(possibly on a different computer). If new uncompressed
input data is produced slowly, without this option xz could
buffer the data for a long time until it would become
decompressible from the output.

If TIMEOUT is 0, the feature is disabled. This is the default.

This commit affects the compression side. Using xz for
the decompression side for the above purpose doesn't work
yet so well because there is quite a bit of input and
output buffering when decompressing.

The --long-help or man page were not updated yet.
The details of this feature may change.
2013-07-04 14:18:46 +03:00
Lasse Collin fa381acaf9 xz: Don't set src_eof=true after an I/O error because it's useless. 2013-07-04 13:41:03 +03:00
Lasse Collin ea00545bea xz: Fix the test when to read more input.
Testing for end of file was no longer correct after full flushing
became possible with --block-size=SIZE and --block-list=SIZES.
There was no bug in practice though because xz just made a few
unneeded zero-byte reads.
2013-07-04 13:25:11 +03:00
Lasse Collin 736903c64b xz: Move some of the timing code into mytime.[hc].
This switches units from microseconds to milliseconds.

New clock_gettime(CLOCK_MONOTONIC) will be used if available.
There is still a fallback to gettimeofday().
2013-07-04 12:51:57 +03:00
Lasse Collin 24edf8d807 Update THANKS. 2013-07-01 14:35:03 +03:00
Lasse Collin c0627b3fce xz: Silence a warning seen with _FORTIFY_SOURCE=2.
Thanks to Christian Hesse.
2013-07-01 14:34:11 +03:00
Lasse Collin 1936718bb3 Update NEWS for 5.0.5. 2013-06-30 19:40:11 +03:00
Lasse Collin a37ae8b5eb Man pages: Use similar syntax for synopsis as in xz.
The man pages of lzmainfo, xzmore, and xzdec had similar
constructs as the man page of xz had before the commit
eb6ca9854b. Eric S. Raymond
didn't mention these man pages in his bug report, but
it's nice to be consistent.
2013-06-30 18:02:27 +03:00
Lasse Collin cdba9ddd87 xz: Use non-blocking I/O for the output file.
Now both reading and writing should be without
race conditions with signals.

They might still be signal handling issues left.
Signals are blocked during many operations to avoid
EINTR but it may cause problems e.g. if writing to
stderr blocks when trying to display an error message.
2013-06-29 15:59:13 +03:00
Lasse Collin e61a5c95da xz: Fix return value type in io_write_buf().
It didn't affect the behavior of the code since -1
becomes true anyway.
2013-06-28 23:56:17 +03:00
Lasse Collin 9dc319eabb xz: Use the self-pipe trick to avoid a race condition with signals.
It is possible that a signal to set user_abort arrives right
before a blocking system call is made. In this case the call
may block until another signal arrives, while the wanted
behavior is to make xz clean up and exit as soon as possible.

After this commit, the race condition is avoided with the
input side which already uses non-blocking I/O. The output
side still uses blocking I/O and thus has the race condition.
2013-06-28 23:48:05 +03:00
Lasse Collin 3541bc79d0 xz: Use non-blocking I/O for the input file. 2013-06-28 22:51:02 +03:00
Lasse Collin 78673a08be xz: Remove an outdated NetBSD-specific comment.
Nowadays errno == EFTYPE is documented in open(2).
2013-06-28 18:46:13 +03:00
Lasse Collin a616fdad34 xz: Fix error detection of fcntl(fd, F_SETFL, flags) calls.
POSIX says that fcntl(fd, F_SETFL, flags) returns -1 on
error and "other than -1" on success. This is how it is
documented e.g. on OpenBSD too. On Linux, success with
F_SETFL is always 0 (at least accorinding to fcntl(2)
from man-pages 3.51).
2013-06-28 18:09:47 +03:00
Lasse Collin 4a08a6e4c6 xz: Fix use of wrong variable in a fcntl() call.
Due to a wrong variable name, when writing a sparse file
to standard output, *all* file status flags were cleared
(to the extent the operating system allowed it) instead of
only clearing the O_APPEND flag. In practice this worked
fine in the common situations on GNU/Linux, but I didn't
check how it behaved elsewhere.

The original flags were still restored correctly. I still
changed the code to use a separate boolean variable to
indicate when the flags should be restored instead of
relying on a special value in stdout_flags.
2013-06-28 17:36:47 +03:00
Lasse Collin b790b435da xz: Fix assertion related to posix_fadvise().
Input file can be a FIFO or something else that doesn't
support posix_fadvise() so don't check the return value
even with an assertion. Nothing bad happens if the call
to posix_fadvise() fails.
2013-06-28 14:55:37 +03:00
Lasse Collin 84d2da6c9d xz: Check the value of lzma_stream_flags.version in --list.
It is a no-op for now, but if an old xz version is used
together with a newer liblzma that supports something new,
then this check becomes important and will stop the old xz
from trying to parse files that it won't understand.
2013-06-26 13:30:57 +03:00
Lasse Collin 9376f5f8f7 Build: Require Automake 1.12 and use serial-tests option.
It should actually still work with Automake 1.10 if
the serial-tests option is removed. Automake 1.13 started
using parallel tests by default and the option to get
the old behavior isn't supported before 1.12.

At least for now, parallel tests don't improve anything
in XZ Utils but they hide the progress output from
test_compress.sh.
2013-06-26 12:17:00 +03:00
Lasse Collin b7e200d7bd Update THANKS. 2013-06-23 18:59:13 +03:00
Lasse Collin 46540e4c10 liblzma: Avoid a warning about a shadowed variable.
On Mac OS X wait() is declared in <sys/wait.h> that
we include one way or other so don't use "wait" as
a variable name.

Thanks to Christian Kujau.
2013-06-23 18:57:23 +03:00
Lasse Collin ebb501ec73 xz: Validate Uncompressed Size from Block Header in list.c.
This affects only "xz -lvv". Normal decompression with xz
already detected if Block Header and Index had mismatched
Uncompressed Size fields. So this just makes "xz -lvv"
show such files as corrupt instead of showing the
Uncompressed Size from Index.
2013-06-23 17:36:47 +03:00
Lasse Collin c09e91dd23 Update THANKS. 2013-06-21 22:08:11 +03:00
Lasse Collin eb6ca9854b xz: Make the man page more friendly to doclifter.
Thanks to Eric S. Raymond.
2013-06-21 22:04:45 +03:00
Lasse Collin 0c0a1947e6 xz: A couple of man page fixes.
Now the interaction of presets and custom filter chains
is described correctly. Earlier it contradicted itself.

Thanks to DevHC who reported these issues on IRC to me
on 2012-12-14.
2013-06-21 21:54:59 +03:00
Lasse Collin 2fcda89939 xz: Fix interaction between preset and custom filter chains.
There was somewhat illogical behavior when --extreme was
specified and mixed with custom filter chains.

Before this commit, "xz -9 --lzma2 -e" was equivalent
to "xz --lzma2". After it is equivalent to "xz -6e"
(all earlier preset options get forgotten when a custom
filter chain is specified and the default preset is 6
to which -e is applied). I find this less illogical.

This also affects the meaning of "xz -9e --lzma2 -7".
Earlier it was equivalent to "xz -7e" (the -e specified
before a custom filter chain wasn't forgotten). Now it
is "xz -7". Note that "xz -7e" still is the same as "xz -e7".

Hopefully very few cared about this in the first place,
so pretty much no one should even notice this change.

Thanks to Conley Moorhous.
2013-06-21 21:50:26 +03:00
Lasse Collin 97379c5ea7 Build: Use -Wvla with GCC if supported.
Variable-length arrays are mandatory in C99 but optional in C11.
The code doesn't currently use any VLAs and it shouldn't in the
future either to stay compatible with C11 without requiring any
optional C11 features.
2013-04-27 22:07:46 +03:00
Lasse Collin 8957c58609 xzdec: Improve the --help message.
The options are now ordered in the same order as in xz's help
message.

Descriptions were added to the options that are ignored.
I left them in parenthesis even if it looks a bit weird
because I find it easier to spot the ignored vs. non-ignored
options from the list that way.
2013-04-15 19:29:09 +03:00
Lasse Collin ed886e1a92 Update THANKS. 2013-04-05 19:25:40 +03:00
Jeff Bastian 5019413a05 xzgrep: make the '-h' option to be --no-filename equivalent
* src/scripts/xzgrep.in: Accept the '-h' option in argument parsing.
2013-04-05 19:14:50 +03:00
Lasse Collin 5ea900cb5a liblzma: Be less picky in lzma_alone_decoder().
To avoid false positives when detecting .lzma files,
rare values in dictionary size and uncompressed size fields
were rejected. They will still be rejected if .lzma files
are decoded with lzma_auto_decoder(), but when using
lzma_alone_decoder() directly, such files will now be accepted.
Hopefully this is an OK compromise.

This doesn't affect xz because xz still has its own file
format detection code. This does affect lzmadec though.
So after this commit lzmadec will accept files that xz or
xz-emulating-lzma doesn't.

NOTE: lzma_alone_decoder() still won't decode all .lzma files
because liblzma's LZMA decoder doesn't support lc + lp > 4.

Reported here:
http://sourceforge.net/projects/lzmautils/forums/forum/708858/topic/7068827
2013-03-23 22:25:15 +02:00
Lasse Collin bb117fffa8 liblzma: Use lzma_block_buffer_bound64() in threaded encoder.
Now it uses lzma_block_uncomp_encode() if the data doesn't
fit into the space calculated by lzma_block_buffer_bound64().
2013-03-23 21:55:13 +02:00
Lasse Collin e572e123b5 liblzma: Fix another deadlock in the threaded encoder.
This race condition could cause a deadlock if lzma_end() was
called before finishing the encoding. This can happen with
xz with debugging enabled (non-debugging version doesn't
call lzma_end() before exiting).
2013-03-23 21:51:38 +02:00
Lasse Collin b465da5988 liblzma: Add lzma_block_uncomp_encode().
This also adds a new internal function
lzma_block_buffer_bound64() which is similar to
lzma_block_buffer_bound() but uses uint64_t instead
of size_t.
2013-03-23 19:17:33 +02:00
Lasse Collin 9e6dabcf22 Avoid unneeded use of awk in xzless.
Use "read" instead of "awk" in xzless to get the version
number of "less". The need for awk was introduced in
the commit db5c1817fa.

Thanks to Ariel P for the patch.
2013-03-05 19:14:50 +02:00
Lasse Collin e7b424d267 Make the progress indicator smooth in threaded mode.
This adds lzma_get_progress() to liblzma and takes advantage
of it in xz.

lzma_get_progress() collects progress information from
the thread-specific structures so that fairly accurate
progress information is available to applications. Adding
a new function seemed to be a better way than making the
information directly available in lzma_stream (like total_in
and total_out are) because collecting the information requires
locking mutexes. It's waste of time to do it more often than
the up to date information is actually needed by an application.
2012-12-14 20:13:32 +02:00
Lasse Collin 2ebbb994e3 liblzma: Fix mythread_sync for nested locking. 2012-12-14 11:01:41 +02:00
Lasse Collin 4c7e28705f xz: Mention --threads in --help.
Thanks to Olivier Delhomme for pointing out that this
was still missing.
2012-12-13 21:05:36 +02:00
Jonathan Nieder db5c1817fa xzless: Make "less -V" parsing more robust
In v4.999.9beta~30 (xzless: Support compressed standard input,
2009-08-09), xzless learned to parse ‘less -V’ output to figure out
whether less is new enough to handle $LESSOPEN settings starting
with “|-”.  That worked well for a while, but the version string from
‘less’ versions 448 (June, 2012) is misparsed, producing a warning:

	$ xzless /tmp/test.xz; echo $?
	/usr/bin/xzless: line 49: test: 456 (GNU regular expressions): \
	integer expression expected
	0

More precisely, modern ‘less’ lists the regexp implementation along
with its version number, and xzless passes the entire version number
with attached parenthetical phrase as a number to "test $a -gt $b",
producing the above confusing message.

	$ less-444 -V | head -1
	less 444
	$ less -V | head -1
	less 456 (no regular expressions)

So relax the pattern matched --- instead of expecting "less <number>",
look for a line of the form "less <number>[ (extra parenthetical)]".
While at it, improve the behavior when no matching line is found ---
instead of producing a cryptic message, we can fall back on a LESSPIPE
setting that is supported by all versions of ‘less’.

The implementation uses "awk" for simplicity.  Hopefully that’s
portable enough.

Reported-by: Jörg-Volker Peetz <jvpeetz@web.de>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
2012-11-21 19:19:44 +02:00
Lasse Collin 65536214a3 xz: Fix the note about --rsyncable on the man page. 2012-10-03 15:54:24 +03:00
Lasse Collin 3d93b63549 xz: Improve handling of failed realloc in xrealloc.
Thanks to Jim Meyering.
2012-09-28 20:11:09 +03:00
Lasse Collin ab22562066 A few typo fixes to comments and the xz man page.
Thanks to Jim Meyering.
2012-08-24 16:27:31 +03:00
Lasse Collin f3c1ec69d9 xz: Add a warning to --help about alpha and beta versions. 2012-08-13 21:40:09 +03:00
Lasse Collin d8eaf9d827 Build: Bump gettext version requirement to 0.18.
Otherwise too old version of m4/lib-link.m4 gets included
when autoreconf -fi is run.
2012-08-02 17:13:30 +03:00
Lasse Collin 96e08902b0 Update THANKS. 2012-07-17 18:29:08 +03:00
Lasse Collin 3778db1be5 liblzma: Make the use of lzma_allocator const-correct.
There is a tiny risk of causing breakage: If an application
assigns lzma_stream.allocator to a non-const pointer, such
code won't compile anymore. I don't know why anyone would do
such a thing though, so in practice this shouldn't cause trouble.

Thanks to Jan Kratochvil for the patch.
2012-07-17 18:19:59 +03:00
Lasse Collin d625c7cf82 Tests: Remove tests/test_block.c that had gotten committed accidentally. 2012-07-05 07:36:28 +03:00
Lasse Collin 0b09d266cc Build: Include macosx/build.sh in the distribution.
It has been in the Git repository since 2010 but probably
few people have seen it since it hasn't been included in
the release tarballs. :-(
2012-07-05 07:33:35 +03:00
Lasse Collin d6e0b23d46 Build: Include validate_map.sh in the distribution.
It's required by "make mydist".

Fix also the location of EXTRA_DIST+= so that those files
get distributed also if symbol versioning isn't enabled.
2012-07-05 07:28:53 +03:00
Lasse Collin 19de545d86 Docs: Fix the name LZMA Utils -> XZ Utils in debug/README. 2012-07-05 07:24:45 +03:00
Lasse Collin 672eccf57c Include debug/translation.bash in the distribution.
Also fix the script name mentioned in README.
2012-07-05 07:23:17 +03:00
Lasse Collin cafb523ada xz: Document --block-list better.
Thanks to Jonathan Nieder.
2012-07-04 22:31:58 +03:00
Lasse Collin c7ff218528 Bump the version number to 5.1.2alpha. 2012-07-04 20:01:49 +03:00
Lasse Collin 8f3c1d886f Update NEWS for 5.1.2alpha. 2012-07-04 20:01:19 +03:00
Lasse Collin 0d5fa05466 xz: Fix the version number printed by xz -lvv.
The decoder bug was fixed in 5.0.2 instead of 5.0.3.
2012-07-04 19:58:23 +03:00
Lasse Collin df11317985 Build: Add a comment to configure.ac about symbol versioning. 2012-07-04 17:11:31 +03:00
Lasse Collin bd9cc179e8 Update TODO. 2012-07-04 17:06:49 +03:00
Lasse Collin 4a238dd9b2 Document --enable-symbol-versions in INSTALL. 2012-07-04 17:05:46 +03:00
Lasse Collin 88ccf47205 xz: Add incomplete support for --block-list.
It's broken with threads and when also --block-size is used.
2012-07-03 21:16:39 +03:00
Lasse Collin 972179cdcd xz: Update the man page about the new field in --robot -lvv. 2012-07-01 18:44:33 +03:00
Lasse Collin 1403707fc6 liblzma: Check that the first byte of range encoded data is 0x00.
It is just to be more pedantic and thus perhaps catch broken
files slightly earlier.
2012-06-28 10:47:49 +03:00
Lasse Collin eccd8017ff Update NEWS from 5.0.4. 2012-06-22 19:00:23 +03:00
Lasse Collin 2e6754eac2 xz: Update man page date to match the latest update. 2012-06-22 14:34:03 +03:00
Lasse Collin b3235a0b1a Docs: Language fix to 01_compress_easy.c.
Thanks to Jonathan Nieder.
2012-06-18 21:27:47 +03:00
Lasse Collin f1675f765f Fix the top-level Makefile.am for the new example programs. 2012-06-14 20:15:30 +03:00
Lasse Collin 3a0c5378ab Docs: Add new example programs.
These have more comments than the old examples and
human-readable error messages. More tutorial-like examples
are needed but these are a start.
2012-06-14 10:52:33 +03:00
Lasse Collin 1bd2c2c553 Docs: Move xz_pipe_comp.c and xz_pipe_decomp.c to doc/examples_old.
It is good to keep these around to so that if someone has
copied the decompressor bug from xz_pipe_decomp.c he has
an example how to easily fix it.
2012-06-14 10:33:27 +03:00
Lasse Collin 905f0ab5b5 Docs: Fix a bug in xz_pipe_decomp.c example program. 2012-06-14 10:33:01 +03:00
Lasse Collin 4bd1a3bd5f Translations: Update the French translation.
Thanks to Adrien Nader.
2012-05-30 23:14:33 +03:00
Lasse Collin d2e836f2f3 Translations: Update the German translation.
The previous only included the new strings in v5.0.
2012-05-29 23:42:37 +03:00
Lasse Collin c9a1615157 Translations: Update the German translation. 2012-05-29 22:26:27 +03:00
Lasse Collin 1530a74fd4 Translations: Update Polish translation. 2012-05-29 22:14:21 +03:00
Lasse Collin d8db706acb liblzma: Fix possibility of incorrect LZMA_BUF_ERROR.
lzma_code() could incorrectly return LZMA_BUF_ERROR if
all of the following was true:

  - The caller knows how many bytes of output to expect
    and only provides that much output space.

  - When the last output bytes are decoded, the
    caller-provided input buffer ends right before
    the LZMA2 end of payload marker. So LZMA2 won't
    provide more output anymore, but it won't know it
    yet and thus won't return LZMA_STREAM_END yet.

  - A BCJ filter is in use and it hasn't left any
    unfiltered bytes in the temp buffer. This can happen
    with any BCJ filter, but in practice it's more likely
    with filters other than the x86 BCJ.

Another situation where the bug can be triggered happens
if the uncompressed size is zero bytes and no output space
is provided. In this case the decompression can fail even
if the whole input file is given to lzma_code().

A similar bug was fixed in XZ Embedded on 2011-09-19.
2012-05-28 20:42:11 +03:00
Lasse Collin 3f94b6d87f Update THANKS. 2012-05-28 15:38:32 +03:00
Lasse Collin 7769ea051d xz: Don't show a huge number in -vv when memory limit is disabled. 2012-05-28 15:37:43 +03:00
Lasse Collin ec92110572 xz: Document the "summary" lines of --robot -lvv.
This documents only the columns that are in v5.0.
The new columns added in the master branch aren't
necessarily stable yet.
2012-05-27 22:30:17 +03:00
Lasse Collin 27d24eb0a9 xz: Fix output of verbose --robot --list modes.
It printed the filename in "filename (x/y)" format
which it obviously shouldn't do in robot mode.
2012-05-27 21:53:20 +03:00
Lasse Collin ab25b82a91 Build: Upgrade m4/acx_pthread.m4 to the latest version. 2012-05-24 18:33:54 +03:00
Lasse Collin d05d6d65c4 Update THANKS. 2012-05-10 21:15:17 +03:00
Lasse Collin e077391982 Docs: Cleanup line wrapping a bit. 2012-05-10 21:14:16 +03:00
Benno Schulenberg fc39849c35 Fix a few typos and add some missing articles in some documents.
Also hyphenate several compound adjectives.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2012-05-10 21:04:23 +03:00
Lasse Collin 29fa0566d5 Windows: Update notes about static linking with MSVC. 2012-04-29 11:51:25 +03:00
Lasse Collin aac1b31ea4 liblzma: Remove outdated comments. 2012-04-19 15:25:26 +03:00
Lasse Collin df14a46013 DOS: Link against DJGPP's libemu to support FPU emulation.
This way xz should work on 386SX and 486SX. Floating point
only is needed for verbose output in xz.
2012-04-19 14:17:52 +03:00
Lasse Collin 03ed742a3a liblzma: Fix Libs.private in liblzma.pc to include -lrt when needed. 2012-04-19 14:02:25 +03:00
Lasse Collin 8c5b13ad59 Docs: Update MINIX 3 information in INSTALL. 2012-04-19 13:58:55 +03:00
Lasse Collin c7376fc415 Update THANKS. 2012-02-22 14:23:13 +02:00
Lasse Collin cff070aba6 Fix exit status of xzgrep when grepping binary files.
When grepping binary files, grep may exit before it has
read all the input. In this case, gzip -q returns 2 (eating
SIGPIPE), but xz and bzip2 show SIGPIPE as the exit status
(e.g. 141). This causes wrong exit status when grepping
xz- or bzip2-compressed binary files.

The fix checks for the special exit status that indicates SIGPIPE.
It uses kill -l which should be supported everywhere since it
is in both SUSv2 (1997) and POSIX.1-2008.

Thanks to James Buren for the bug report.
2012-02-22 14:02:34 +02:00
Lasse Collin 41cafb2bf9 Update THANKS. 2012-02-22 12:08:43 +02:00
Lasse Collin 2dcea03712 Fix compiling with IBM XL C on AIX. 2012-02-22 12:00:16 +02:00
Lasse Collin 7db6bdf4ab Tests: Fix a compiler warning with _FORTIFY_SOURCE.
Reported here:
http://sourceforge.net/projects/lzmautils/forums/forum/708858/topic/4927385
2012-01-10 17:13:03 +02:00
Lasse Collin 694952d545 Docs: Explain the stable releases better in README. 2011-12-19 21:21:29 +02:00
Lasse Collin 418fe668b3 xz: Show minimum required XZ Utils version in xz -lvv.
Man page wasn't updated yet.
2011-11-07 13:07:52 +02:00
Lasse Collin 7081d82c37 xz: Fix a typo in a comment.
Thanks to Bela Lubkin.
2011-11-04 17:57:16 +02:00
Lasse Collin 232fe7cd70 Update THANKS. 2011-11-03 17:08:02 +02:00
Lasse Collin 74d2bae4d3 xz: Fix xz on EBCDIC systems.
Thanks to Chris Donawa.
2011-11-03 17:07:22 +02:00
Lasse Collin 4ac4923f47 Update THANKS. 2011-10-23 17:09:10 +03:00
Lasse Collin ab50ae3ef4 liblzma: Fix invalid free() in the threaded encoder.
It was triggered if initialization failed e.g. due to
running out of memory.

Thanks to Arkadiusz Miskiewicz.
2011-10-23 17:08:14 +03:00
Lasse Collin 6b620a0f08 liblzma: Fix a deadlock in the threaded encoder.
It was triggered when reinitializing the encoder,
e.g. when encoding two files.
2011-10-23 17:05:55 +03:00
Lasse Collin bd52cf150e Build: Fix "make check" on Windows. 2011-09-06 12:03:41 +03:00
Lasse Collin 5c5b225696 Update THANKS. 2011-08-09 21:19:13 +03:00
Lasse Collin 5b1e1f1074 Workaround unusual SIZE_MAX on SCO OpenServer. 2011-08-09 21:16:44 +03:00
Lasse Collin e9ed88126e Run the scripts with the correct shell in test_scripts.sh.
The scripts are now made executable in the build tree.
This way the scripts can be run like programs in
test_scripts.sh. Previously test_scripts.sh always
used sh but it's not correct if @POSIX_SHELL@ is set
to something else by configure.

Thanks to Jonathan Nieder for the patch.
2011-08-06 20:37:28 +03:00
Lasse Collin 1c673e5681 Fix exit status of "xzdiff foo.xz bar.xz".
xzdiff was clobbering the exit status from diff in a case
statement used to analyze the exit statuses from "xz" when
its operands were two compressed files. Save and restore
diff's exit status to fix this.

The bug is inherited from zdiff in GNU gzip and was fixed
there on 2009-10-09.

Thanks to Jonathan Nieder for the patch and
to Peter Pallinger for reporting the bug.
2011-07-31 11:01:47 +03:00
Lasse Collin 324cde7a86 liblzma: Remove unneeded semicolon. 2011-06-16 12:15:29 +03:00
Lasse Collin 492c863455 Build: Make configure print if symbol versioning is enabled or not. 2011-05-28 19:24:56 +03:00
Lasse Collin fc4d443696 Don't call close(-1) in tuklib_open_stdxxx() on error.
Thanks to Jim Meyering.
2011-05-28 16:43:26 +03:00
Lasse Collin bd35d903a0 liblzma: Use symbol versioning.
Symbol versioning is enabled by default on GNU/Linux,
other GNU-based systems, and FreeBSD.

I'm not sure how stable this is, so it may need
backward-incompatible changes before the next release.

The idea is that alpha and beta symbols are considered
unstable and require recompiling the applications that
use those symbols. Once a symbol is stable, it may get
extended with new features in ways that don't break
compatibility with older ABI & API.

The mydist target runs validate_map.sh which should
catch some probable problems in liblzma.map. Otherwise
I would forget to update the map file for new releases.
2011-05-28 15:55:39 +03:00
Lasse Collin afbb244362 Translations: Update the Italian translation.
Thanks to Milo Casagrande.
2011-05-28 09:46:46 +03:00
Lasse Collin 79bef85e05 Tests: Add a test file for the bug in the previous commit. 2011-05-28 08:46:04 +03:00
Lasse Collin c029744506 xz: Fix error handling in xz -lvv.
It could do an invalid free() and read past the end
of the uninitialized filters array.
2011-05-27 22:25:44 +03:00
Lasse Collin 8bd91918ac liblzma: Handle allocation failures correctly in lzma_index_init().
Thanks to Jim Meyering.
2011-05-27 22:09:49 +03:00
Lasse Collin fe00f95828 Build: Fix checking for system-provided SHA-256. 2011-05-24 00:23:46 +03:00
Lasse Collin 21b45b9bab Build: Set GZIP_ENV=-9n in top-level Makefile.am. 2011-05-23 18:30:30 +03:00
Lasse Collin 48053e8a45 Update NEWS for 5.0.3. 2011-05-22 16:42:11 +03:00
Lasse Collin bba37df2c9 Add French translation.
It is known that the BCJ filter --help text is only
partially translated.
2011-05-21 16:28:44 +03:00
Lasse Collin 4161d76349 xz: Translate also the string used to print the program name.
French needs a space before a colon, e.g. "xz : foo error".
2011-05-21 15:12:10 +03:00
Lasse Collin b94aa0c838 liblzma: Try to use SHA-256 from the operating system.
If the operating system libc or other base libraries
provide SHA-256, use that instead of our own copy.
Note that this doesn't use OpenSSL or libgcrypt or
such libraries to avoid creating dependencies to
other packages.

This supports at least FreeBSD, NetBSD, OpenBSD, Solaris,
MINIX, and Darwin. They all provide similar but not
identical SHA-256 APIs; everyone is a little different.

Thanks to Wim Lewis for the original patch, improvements,
and testing.
2011-05-21 15:08:44 +03:00
Lasse Collin f004128678 Don't use clockid_t in mythread.h when clock_gettime() isn't available.
Thanks to Wim Lewis for the patch.
2011-05-17 12:52:18 +03:00
Lasse Collin f779516f42 Update THANKS. 2011-05-17 12:26:28 +03:00
Lasse Collin 830ba58777 Update INSTALL with a note about linker problem on OpenSolaris x86. 2011-05-17 12:21:33 +03:00
Lasse Collin ec7106309c Build: Fix initialization of enable_check_* variables in configure.ac.
This doesn't matter much in practice since it is unlikely
that anyone would have such environment variable names.

Thanks to Wim Lewis.
2011-05-17 12:01:37 +03:00
Lasse Collin 4c6e146df9 Add underscores to attributes (__attribute((__foo__))). 2011-05-17 11:54:38 +03:00
Lasse Collin 7a480e4859 xz: Fix input file position when --single-stream is used.
Now the following works as you would expect:

    echo foo | xz > foo.xz
    echo bar | xz >> foo.xz
    ( xz -dc --single-stream ; xz -dc --single-stream ) < foo.xz

Note that it doesn't work if the input is not seekable
or if there is Stream Padding between the concatenated
.xz Streams.
2011-05-01 12:24:23 +03:00
Lasse Collin c29e6630c1 xz: Print the maximum number of worker threads in xz -vv. 2011-05-01 12:15:51 +03:00
Lasse Collin 0b77c4a751 Build: Warn if no supported method to detect the number of CPU cores. 2011-04-19 10:44:48 +03:00
Lasse Collin e4622df9ab Update THANKS. 2011-04-19 09:55:06 +03:00
Lasse Collin 9c1b05828a Fix portability problems in mythread.h.
Use gettimeofday() if clock_gettime() isn't available
(e.g. Darwin).

The test for availability of pthread_condattr_setclock()
and CLOCK_MONOTONIC was incorrect. Instead of fixing the
#ifdefs, use an Autoconf test. That way if there exists a
system that supports them but doesn't specify the matching
POSIX #defines, the features will still get detected.

Don't try to use pthread_sigmask() on OpenVMS. It doesn't
have that function.

Guard mythread.h against being #included multiple times.
2011-04-19 09:20:44 +03:00
Lasse Collin 3de00cc75d Update THANKS. 2011-04-18 19:35:49 +03:00
Martin Väth bd5002f582 xzgrep: fix typo in $0 parsing
Reported-by: Diego Elio Pettenò <flameeyes@gentoo.org>
Signed-off-by: Martin Väth <vaeth@mathematik.uni-wuerzburg.de>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-04-18 19:33:27 +03:00
Lasse Collin 6ef4eabc0a Bump the version number to 5.1.1alpha and liblzma soname to 5.0.99. 2011-04-12 12:48:31 +03:00
Lasse Collin 9a4377be0d Put the unstable APIs behind #ifdef LZMA_UNSTABLE.
This way people hopefully won't complain if these APIs
change and break code that used an older API.
2011-04-12 12:42:37 +03:00
Lasse Collin 3e321a3acd Remove doubled words from documentation and comments.
Spot candidates by running these commands:
  git ls-files |xargs perl -0777 -n \
    -e 'while (/\b(then?|[iao]n|i[fst]|but|f?or|at|and|[dt]o)\s+\1\b/gims)' \
    -e '{$n=($` =~ tr/\n/\n/ + 1); ($v=$&)=~s/\n/\\n/g; print "$ARGV:$n:$v\n"}'

Thanks to Jim Meyering for the original patch.
2011-04-12 11:59:49 +03:00
Lasse Collin d91a84b534 Update NEWS. 2011-04-12 11:46:01 +03:00
Lasse Collin 14e6ad8cfe Update TODO. 2011-04-12 11:45:40 +03:00
Lasse Collin 70e750f597 xz: Update the man page about threading. 2011-04-12 11:08:55 +03:00
Lasse Collin 24e0406c0f xz: Add support for threaded compression. 2011-04-11 22:06:03 +03:00
Lasse Collin de678e0c92 liblzma: Add lzma_stream_encoder_mt() for threaded compression.
This is the simplest method to do threading, which splits
the uncompressed data into blocks and compresses them
independently from each other. There's room for improvement
especially to reduce the memory usage, but nevertheless,
this is a good start.
2011-04-11 22:03:30 +03:00
Lasse Collin 25fe729532 liblzma: Add the forgotten lzma_lzma2_block_size().
This should have been in 5eefc0086d.
2011-04-11 21:15:07 +03:00
Lasse Collin 91afb785a1 liblzma: Document lzma_easy_(enc|dec)oder_memusage() better too. 2011-04-11 21:04:13 +03:00
Lasse Collin 4a9905302a liblzma: Document lzma_raw_(enc|dec)oder_memusage() better.
It didn't mention the return value that is used if
an error occurs.
2011-04-11 20:59:07 +03:00
Lasse Collin 0badb0b1bd liblzma: Use memzero() to initialize supported_actions[].
This is cleaner and makes it simpler to add new members
to lzma_action enumeration.
2011-04-11 19:28:18 +03:00
Lasse Collin a7934c446a liblzma: API comment about lzma_allocator with threaded coding. 2011-04-11 19:26:27 +03:00
Lasse Collin 5eefc0086d liblzma: Add an internal function lzma_mt_block_size().
This is based lzma_chunk_size() that was included in some
development version of liblzma.
2011-04-11 19:16:30 +03:00
Lasse Collin d119927475 liblzma: Don't create an empty Block in lzma_stream_buffer_encode().
Empty Block was created if the input buffer was empty.
Empty Block wastes a few bytes of space, but more importantly
it triggers a bug in XZ Utils 5.0.1 and older when trying
to decompress such a file. 5.0.1 and older consider such
files to be corrupt. I thought that no encoder creates empty
Blocks when releasing 5.0.2 but I was wrong.
2011-04-11 13:59:50 +03:00
Lasse Collin 3b22fc2c87 liblzma: Fix API docs to mention LZMA_UNSUPPORTED_CHECK.
This return value was missing from the API comments of
four functions.
2011-04-11 13:28:40 +03:00
Lasse Collin 71b9380145 liblzma: Validate encoder arguments better.
The biggest problem was that the integrity check type
wasn't validated, and e.g. lzma_easy_buffer_encode()
would create a corrupt .xz Stream if given an unsupported
Check ID. Luckily applications don't usually try to use
an unsupport Check ID, so this bug is unlikely to cause
many real-world problems.
2011-04-11 13:21:28 +03:00
Lasse Collin ec7e3dbad7 xz: Move the description of --block-size in --long-help. 2011-04-11 09:57:30 +03:00
Lasse Collin cd3086ff44 Docs: Document --single-stream and --block-size. 2011-04-11 09:55:35 +03:00
Lasse Collin fb64a49243 liblzma: Make lzma_stream_encoder_init() static (second try).
It's an internal function and it's not needed by
anything outside stream_encoder.c.
2011-04-11 09:27:57 +03:00
Lasse Collin a34730cf6a Revert "liblzma: Make lzma_stream_encoder_init() static."
This reverts commit 352ac82db5.
I don't know what I was thinking.
2011-04-11 08:31:42 +03:00
Lasse Collin 9f0a806aef Revise mythread.h.
This adds:

  - mythread_sync() macro to create synchronized blocks

  - mythread_cond structure and related functions
    and macros for condition variables with timed
    waiting using a relative timeout

  - mythread_create() to create a thread with all
    signals blocked

Some of these wouldn't need to be inline functions,
but I'll keep them this way for now for simplicity.

For timed waiting on a condition variable, librt is
now required on some systems to use clock_gettime().
configure.ac was updated to handle this.
2011-04-10 21:23:21 +03:00
Lasse Collin 352ac82db5 liblzma: Make lzma_stream_encoder_init() static.
It's an internal function and it's not needed by
anything outside stream_encoder.c.
2011-04-10 20:37:36 +03:00
Lasse Collin 9e807fe3fe DOS: Update the docs and include notes about 8.3 filenames. 2011-04-10 14:58:10 +03:00
Lasse Collin ebd54dbd6e xz/DOS: Add experimental 8.3 filename support.
This is incompatible with the 8.3 support patch made by
Juan Manuel Guerrero. I think this one is nicer, but
I need to get feedback from DOS users before saying
that this is the final version of 8.3 filename support.
2011-04-10 13:09:42 +03:00
Lasse Collin cd4fe97852 xz/DOS: Be more careful with the destination file.
Try to avoid overwriting the source file if --force is
used and the generated destination filename refers to
the source file. This can happen with 8.3 filenames where
extra characters are ignored.

If the generated output file refers to a special file
like "con" or "prn", refuse to write to it even if --force
is used.
2011-04-10 12:47:47 +03:00
Lasse Collin 607f9f98ae Update THANKS. 2011-04-09 18:29:30 +03:00
Lasse Collin fca396b374 liblzma: Add missing #ifdefs to filter_common.c.
Passing --disable-decoders to configure broke a few
encoders due to missing #ifdefs in filter_common.c.

Thanks to Jason Gorski for the patch.
2011-04-09 18:28:58 +03:00
Lasse Collin b03f6cd3eb xz: Avoid unneeded fstat() on DOS-like systems. 2011-04-09 15:24:59 +03:00
Lasse Collin 335fe260a8 xz: Minor internal changes to handling of --threads.
Now it always defaults to one thread. Maybe this
will change again if a threading method is added
that doesn't affect memory usage.
2011-04-09 15:11:13 +03:00
Lasse Collin 9edd6ee895 xz: Change size_t to uint32_t in a few places. 2011-04-08 17:53:05 +03:00
Lasse Collin 411013ea45 xz: Fix a typo in a comment. 2011-04-08 17:48:41 +03:00
Lasse Collin b34c5ce4b2 liblzma: Use TUKLIB_GNUC_REQ to check GCC version in sha256.c. 2011-04-05 22:41:33 +03:00
Lasse Collin db33117cc8 Build: Upgrade m4/acx_pthread.m4 to the latest version.
It was renamed to ax_pthread.m4 in Autoconf Archive.
2011-04-05 17:12:20 +03:00
Lasse Collin 1039bfcfc0 xz: Use posix_fadvise() if it is available. 2011-04-05 15:27:26 +03:00
Lasse Collin 1ef3cf44a8 xz: Call lzma_end(&strm) before exiting if debugging is enabled. 2011-04-05 15:13:29 +03:00
Lasse Collin bd432015d3 liblzma: Fix a memory leak in stream_encoder.c.
It leaks old filter options structures (hundred bytes or so)
every time the lzma_stream is reinitialized. With the xz tool,
this happens when compressing multiple files.
2011-04-02 14:49:56 +03:00
Lasse Collin 1688901321 Updated NEWS for 5.0.2. 2011-04-01 13:25:05 +03:00
Lasse Collin 85cdf7dd4e Update INSTALL with another note about IRIX. 2011-03-31 15:06:58 +03:00
Lasse Collin c3f4995586 Tests: Add a new file to test empty LZMA2 streams. 2011-03-31 12:22:55 +03:00
Lasse Collin 0d21f49a80 liblzma: Fix decoding of LZMA2 streams having no uncompressed data.
The decoder considered empty LZMA2 streams to be corrupt.
This shouldn't matter much with .xz files, because no encoder
creates empty LZMA2 streams in .xz. This bug is more likely
to cause problems in applications that use raw LZMA2 streams.
2011-03-31 11:54:48 +03:00
Lasse Collin 40277998cb Scripts: Better fix for xzgrep.
Now it uses "grep -q".

Thanks to Gregory Margo.
2011-03-24 01:42:49 +02:00
Lasse Collin 2118733045 Updated THANKS. 2011-03-24 01:22:18 +02:00
Lasse Collin c7210d9a3f Scripts: Fix xzgrep -l.
It didn't work at all. It tried to use the -q option
for grep, but it appended it after "--". This works
around it by redirecting to /dev/null. The downside
is that this can be slower with big files compared
to proper use of "grep -q".

Thanks to Gregory Margo.
2011-03-24 01:21:32 +02:00
Lasse Collin 4eb83e3204 Scripts: Add lzop (.lzo) support to xzdiff and xzgrep. 2011-03-19 13:08:22 +02:00
Lasse Collin 923b22483b xz: Add --block-size=SIZE.
This uses LZMA_FULL_FLUSH every SIZE bytes of input.

Man page wasn't updated yet.
2011-03-18 19:10:30 +02:00
Lasse Collin 57597d42ca xz: Add --single-stream.
This can be useful when there is garbage after the
compressed stream (.xz, .lzma, or raw stream).

Man page wasn't updated yet.
2011-03-18 18:19:19 +02:00
Lasse Collin 96f94bc925 xz: Clean up suffix.c.
struct suffix_pair isn't needed in compresed_name()
so get rid of it there.
2011-02-06 20:16:14 +02:00
Lasse Collin 8930c7ae3f xz: Check if the file already has custom suffix when compressing.
Now "xz -S .test foo.test" refuses to compress the
file because it already has the suffix .test. The man
page had it documented this way already.
2011-02-06 20:16:14 +02:00
Lasse Collin 940d5852c6 Updated THANKS. 2011-02-06 20:16:14 +02:00
Lasse Collin 4ebe65f839 Translations: Add Polish translation.
Thanks to Jakub Bogusz.
2011-02-06 20:16:14 +02:00
Lasse Collin fc1d292dca Updated THANKS. 2011-02-06 20:16:14 +02:00
Lasse Collin 6dd061adfd Merge commit '5fbce0b8d96dc96775aa0215e3581addc830e23d' 2011-02-06 20:13:01 +02:00
Lasse Collin 9d542ceebc Merge branch 'v5.0' 2011-01-19 11:45:35 +02:00
Lasse Collin 4f2c69a4e3 Merge branch 'v5.0' 2010-12-12 23:13:22 +02:00
Lasse Collin adb89e68d4 Merge branch 'v5.0' 2010-12-07 18:53:04 +02:00
Lasse Collin 7c24e0d1b8 Merge branch 'v5.0' 2010-11-15 14:33:01 +02:00
Anders F Bjorklund b4d42f1a71 add build script for macosx universal 2010-11-08 14:22:43 +02:00
Lasse Collin 15ee6935ab Update the copies of GPLv2 and LGPLv2.1 from gnu.org.
There are only a few white space changes.
2010-11-04 18:31:40 +02:00
Lasse Collin 8e355f7fdb Merge branch 'v5.0' 2010-10-26 15:53:06 +03:00
Lasse Collin 974ebe6349 liblzma: Rename a few variables and constants.
This has no semantic changes. I find the new names slightly
more logical and they match the names that are already used
in XZ Embedded.

The name fastpos wasn't changed (not worth the hassle).
2010-10-26 10:36:41 +03:00
Lasse Collin 7c427ec38d Bump version 5.1.0alpha. 2010-10-25 12:59:25 +03:00
455 changed files with 96886 additions and 11195 deletions

24
.codespellrc Normal file
View File

@ -0,0 +1,24 @@
[codespell]
# Skip all translation files and a few other autogenerated files.
# The autotool files should have their typos fixed in the upstream, but
# until then we will blacklist them here.
skip = *.po,*.pot,./po4a/man,./doc/api,./configure,./autom4te.cache,./m4/libtool.m4,./build-aux/depcomp,./build-aux/ltmain.sh,./build-aux/config.guess,./build-aux/config.rpath,./m4/po.m4,./build-aux/config.sub
# Ignore false positive matching words. Ideally codespell would allow
# ignoring words for specific files, but that does not appear to be
# supported. Instead we need to hope we do not make these typos.
# Additionally, the ignored words must be specified lower-case even though
# some of the false positives only occurred upper-case.
# ANS - used as a variable name in xzmore.in.
# bu - groff syntax for creating a bullet list item, used in xz.1.
# te - groff syntax, used in xz.1.
# caf - command line options for tar example, used in xz.1.
ignore-words-list = ans,bu,te,caf
# Add extra dictionaries to help improvement comments, docs, etc.
builtin = clear,rare,informal,usage,names
# Always default to highest interactive level to avoid accidentally
# changing a false positive or picking the wrong replacement.
interactive = 3

23
.github/SECURITY.md vendored Normal file
View File

@ -0,0 +1,23 @@
# Security Policy
## Supported Versions
We provide security updates to the development branch and the stable
branches. Security patches for old releases are available on the
[project website](https://xz.tukaani.org/xz-utils/).
## Reporting a Vulnerability
If you discover a security vulnerability in this project, please
report it privately. **Do not disclose it as a public issue.** This gives
us time to work with you to fix the issue before public exposure, reducing
the chance that the exploit will be used before a patch is released.
You may submit a report by emailing us at
[xz@tukaani.org](mailto:xz@tukaani.org), or through
[Security Advisories](https://github.com/tukaani-project/xz/security/advisories/new).
While both options are available, we prefer email.
This project is maintained by a team of volunteers on a reasonable-effort
basis. As such, please give us 90 days to work on a fix before
public exposure.

160
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,160 @@
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# Author: Jia Tan
#
#############################################################################
name: CI
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]
# Allows running workflow manually
workflow_dispatch:
jobs:
POSIX:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
build_system: [autotools, cmake]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 #v4.1.0
########################
# Install Dependencies #
########################
# Install Autotools on Linux
- name: Install Dependencies
if: ${{ matrix.os == 'ubuntu-latest' && matrix.build_system == 'autotools' }}
run: |
sudo apt-get update
sudo apt-get install -y autoconf automake build-essential po4a autopoint gcc-multilib doxygen musl-tools
# Install Autotools on Mac
- name: Install Dependencies
if: ${{ matrix.os == 'macos-latest' && matrix.build_system == 'autotools' }}
run: brew install autoconf automake libtool po4a doxygen
# Install CMake on Linux
- name: Install Dependencies
if: ${{ matrix.os == 'ubuntu-latest' && matrix.build_system == 'cmake' }}
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake musl-tools
# Install CMake on Mac
- name: Install Dependencies
if: ${{ matrix.os == 'macos-latest' && matrix.build_system == 'cmake' }}
run: brew install cmake
##################
# Build and Test #
##################
# -b specifies the build system to use.
# -p specifies the phase (build or test) to help narrow down an error
# if one occurs.
#
# The first two builds/tests are only run on Autotools Linux and
# affect the CFLAGS. Resetting the CFLAGS requires clearing the
# config cache between runs, so the tests that require CFLAGS are
# done first.
- name: Build 32-bit
if: ${{ matrix.os == 'ubuntu-latest' && matrix.build_system == 'autotools' }}
run: ./build-aux/ci_build.sh -b autotools -p build -f "-m32"
- name: Test 32-bit
if: ${{ matrix.os == 'ubuntu-latest' && matrix.build_system == 'autotools' }}
run: |
./build-aux/ci_build.sh -b autotools -p test -f "-m32" -n 32_bit
cd ../xz_build && make distclean
# ifunc must be disabled for this test because __attribute__ ifunc is
# incompatible with -fsanitize=address.
#
# The sandbox must also be disabled because it will prevent access to
# the /proc/ filesystem on Linux, which is used by the sanitizer's
# instrumentation.
- name: Build with -fsanitize=address,undefined
if: ${{ matrix.os == 'ubuntu-latest' && matrix.build_system == 'autotools' }}
run: ./build-aux/ci_build.sh -b autotools -p build -f "-fsanitize=address,undefined" -d ifunc,sandbox
- name: Test with -fsanitize=address,undefined
if: ${{ matrix.os == 'ubuntu-latest' && matrix.build_system == 'autotools' }}
run: |
./build-aux/ci_build.sh -b autotools -p test -f "-fsanitize=address,undefined" -d ifunc,sandbox
cd ../xz_build && make distclean
# musl libc has some slight differences compared to glibc, including
# the lack of ifunc support. This tests if the ifunc detection
# functions properly since musl-gcc can compile with ifunc support,
# but will fail at runtime.
- name: Build with musl libc
if: ${{ matrix.os == 'ubuntu-latest'}}
run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -p build -m "/usr/bin/musl-gcc"
- name: Test with musl libc
if: ${{ matrix.os == 'ubuntu-latest'}}
run: |
./build-aux/ci_build.sh -b ${{ matrix.build_system }} -p test -m "/usr/bin/musl-gcc"
- name: Clean up musl libc run
if: ${{ matrix.os == 'ubuntu-latest' && matrix.build_system == 'autotools' }}
run: cd ../xz_build && make distclean
- name: Build with full features
run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -p build
- name: Test with full features
run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -p test -n full_features
- name: Build without encoders
run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -d encoders,shared -p build
- name: Test without encoders
run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -d encoders,shared -p test -n no_encoders
- name: Build without decoders
run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -d decoders,shared -p build
- name: Test without decoders
run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -d decoders,shared -p test -n no_decoders
- name: Build without threads
run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -d threads,shared -p build
- name: Test without threads
run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -d threads,shared -p test -n no_threads
- name: Build without BCJ filters
run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -d bcj,shared,nls -p build
- name: Test without BCJ filters
run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -d bcj,shared,nls -p test -n no_bcj
- name: Build without Delta filters
run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -d delta,shared,nls -p build
- name: Test without Delta filters
run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -d delta,shared,nls -p test -n no_delta
- name: Build without sha256 check
run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -c crc32,crc64 -d shared,nls -p build
- name: Test without sha256 check
run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -c crc32,crc64 -d shared,nls -p test -n no_sha256
- name: Build without crc64 check
run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -c crc32,sha256 -d shared,nls -p build
- name: Test without crc64 check
run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -c crc32,sha256 -d shared,nls -p test -n no_crc64
- name: Build small
run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -d small -p build
- name: Test small
run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -d small -p test -n small
# Attempt to upload the test logs as artifacts if any step has failed
- uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 #v4.0.0
if: ${{ failure() }}
with:
name: ${{ matrix.os }} ${{ matrix.build_system }} Test Logs
path: build-aux/artifacts

124
.github/workflows/windows-ci.yml vendored Normal file
View File

@ -0,0 +1,124 @@
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# Author: Jia Tan
#
#############################################################################
name: Windows-CI
# Only run the Windows CI manually since it takes much longer than the others.
on: workflow_dispatch
jobs:
POSIX:
strategy:
matrix:
# Test different environments since the code may change between
# them and we want to ensure that we support all potential users.
# clang64 builds are currently broken when building static libraries
# due to a bug in ldd search path:
# https://github.com/llvm/llvm-project/issues/67779
# TODO - re-enable clang64 when this is resolved.
msys2_env: [mingw64, mingw32, ucrt64, msys]
build_system: [autotools, cmake]
# Set the shell to be msys2 as a default to avoid setting it for
# every individual run command.
defaults:
run:
shell: msys2 {0}
runs-on: windows-latest
steps:
#####################
# Setup Environment #
#####################
# Rely on the msys2 GitHub Action to set up the msys2 environment.
- name: Setup MSYS2
uses: msys2/setup-msys2@27b3aa77f672cb6b3054121cfd80c3d22ceebb1d #v2.20.1
with:
msystem: ${{ matrix.msys2_env }}
update: true
install: pactoys make
- name: Checkout code
# Need to explicitly set the shell here since we set the default
# shell as msys2 earlier. This avoids an extra msys2 dependency on
# git.
shell: powershell
# Avoid Windows line endings. Otherwise test_scripts.sh will fail
# because the expected output is stored in the test framework as a
# text file and will not match the output from xzgrep.
run: git config --global core.autocrlf false
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 #v4.1.0
########################
# Install Dependencies #
########################
# The pacman repository has a different naming scheme for default
# msys packages than the others. The pacboy tool allows installing
# the packages possible in matrix setup without a burdensome amount
# of ifs.
- name: Install Dependencies
if: ${{ matrix.msys2_env == 'msys' && matrix.build_system == 'autotools' }}
run: pacman --noconfirm -S --needed autotools base-devel doxygen gettext-devel gcc
- name: Install Dependencies
if: ${{ matrix.msys2_env != 'msys' && matrix.build_system == 'autotools' }}
run: pacboy --noconfirm -S --needed autotools:p toolchain:p doxygen:p
- name: Install Dependencies
if: ${{ matrix.msys2_env == 'msys' && matrix.build_system == 'cmake' }}
run: pacman --noconfirm -S --needed cmake base-devel gcc
- name: Install Dependencies
if: ${{ matrix.msys2_env != 'msys' && matrix.build_system == 'cmake' }}
run: pacboy --noconfirm -S --needed cmake:p toolchain:p
##################
# Build and Test #
##################
- name: Build with full features
run: ./build-aux/ci_build.sh -a "--no-po4a" -b ${{ matrix.build_system }} -p build
- name: Test with full features
run: ./build-aux/ci_build.sh -a "--no-po4a" -b ${{ matrix.build_system }} -p test -n full_features
- name: Build without threads
run: ./build-aux/ci_build.sh -a "--no-po4a" -b ${{ matrix.build_system }} -d threads,shared -p build
- name: Test without threads
run: ./build-aux/ci_build.sh -a "--no-po4a" -b ${{ matrix.build_system }} -d threads,shared -p test -n no_threads
- name: Build without encoders
run: ./build-aux/ci_build.sh -a "--no-po4a" -b ${{ matrix.build_system }} -d encoders,shared -p build
- name: Test without encoders
run: ./build-aux/ci_build.sh -a "--no-po4a" -b ${{ matrix.build_system }} -d encoders,shared -p test -n no_encoders
- name: Build without decoders
run: ./build-aux/ci_build.sh -a "--no-po4a" -b ${{ matrix.build_system }} -d decoders,shared -p build
- name: Test without decoders
run: ./build-aux/ci_build.sh -a "--no-po4a" -b ${{ matrix.build_system }} -d decoders,shared -p test -n no_decoders
- name: Build with only crc32 check
run: ./build-aux/ci_build.sh -a "--no-po4a" -b ${{ matrix.build_system }} -c crc32 -d shared,nls -p build
- name: Test with only crc32 check
run: ./build-aux/ci_build.sh -a "--no-po4a" -b ${{ matrix.build_system }} -c crc32 -d shared,nls -p test -n crc32_only
###############
# Upload Logs #
###############
# Upload the test logs as artifacts if any step has failed.
- uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 #v4.0.0
if: ${{ failure() }}
with:
name: ${{ matrix.msys2_env }} ${{ matrix.build_system }} Test Logs
path: build-aux/artifacts

50
.gitignore vendored
View File

@ -1,9 +1,13 @@
*~
*.bak
*.bak[0-9]
.gdb_history
.deps
.libs
*.a
*.gcda
*.gcno
*.la
*.lo
*.o
@ -21,6 +25,7 @@ Makefile.in
/libtool
/stamp-h1
build-aux/artifacts
build-aux/compile
build-aux/config.guess
build-aux/config.rpath
@ -29,6 +34,12 @@ build-aux/depcomp
build-aux/install-sh
build-aux/ltmain.sh
build-aux/missing
build-aux/test-driver
coverage
/doc/internal
/doc/api
/src/liblzma/liblzma.pc
/src/lzmainfo/lzmainfo
@ -41,15 +52,28 @@ build-aux/missing
/src/scripts/xzless
/src/scripts/xzmore
/tests/*.log
/tests/*.trs
/tests/compress_generated_abc
/tests/compress_generated_random
/tests/compress_generated_text
/tests/create_compress_files
/tests/test_bcj_exact_size
/tests/test_block_header
/tests/test_check
/tests/test_filter_flags
/tests/test_filter_str
/tests/test_hardware
/tests/test_index
/tests/test_index_hash
/tests/test_lzip_decoder
/tests/test_microlzma
/tests/test_memlimit
/tests/test_stream_flags
/tests/test_vli
/tests/xzgrep_test_1.xz
/tests/xzgrep_test_2.xz
/tests/xzgrep_test_output
/lib/Makefile
/tests/Makefile
@ -62,3 +86,29 @@ build-aux/missing
/src/liblzma/api/Makefile
/src/lzmainfo/Makefile
/src/xzdec/Makefile
/CMakeCache.txt
/CMakeFiles
/CTestTestfile.cmake
/cmake_install.cmake
/DartConfiguration.tcl
/liblzma-config-version.cmake
/liblzma-config.cmake
/lzcat
/lzcat.1
/lzma
/lzma.1
/Testing
/tests_bin/
/unlzma
/unlzma.1
/unxz
/unxz.1
/xz
/xzcat
/xzcat.1
/xzdec
/windows/*/.vs
/windows/*/liblzma.vcxproj.user
/.vscode/

54
AUTHORS
View File

@ -3,25 +3,51 @@ Authors of XZ Utils
===================
XZ Utils is developed and maintained by Lasse Collin
<lasse.collin@tukaani.org>.
<lasse.collin@tukaani.org> and Jia Tan <jiat0218@gmail.com>.
Major parts of liblzma are based on code written by Igor Pavlov,
specifically the LZMA SDK <http://7-zip.org/sdk.html>. Without
specifically the LZMA SDK <https://7-zip.org/sdk.html>. Without
this code, XZ Utils wouldn't exist.
The SHA-256 implementation in liblzma is based on the code found from
7-Zip <http://7-zip.org/>, which has a modified version of the SHA-256
code found from Crypto++ <http://www.cryptopp.com/>. The SHA-256 code
in Crypto++ was written by Kevin Springle and Wei Dai.
The SHA-256 implementation in liblzma is based on code written by
Wei Dai in Crypto++ Library <https://www.cryptopp.com/>.
Some scripts have been adapted from gzip. The original versions
were written by Jean-loup Gailly, Charles Levert, and Paul Eggert.
Andrew Dudman helped adapting the script and their man pages for
XZ Utils.
A few scripts have been adapted from GNU gzip. The original
versions were written by Jean-loup Gailly, Charles Levert, and
Paul Eggert. Andrew Dudman helped adapting the scripts and their
man pages for XZ Utils.
The GNU Autotools based build system contains files from many authors,
which I'm not trying list here.
The initial version of the threaded .xz decompressor was written
by Sebastian Andrzej Siewior.
Several people have contributed fixes or reported bugs. Most of them
are mentioned in the file THANKS.
The initial version of the .lz (lzip) decoder was written
by Michał Górny.
Architecture-specific CRC optimizations were contributed by
Ilya Kurdyukov, Hans Jansen, and Chenxi Mao.
Other authors:
- Jonathan Nieder
- Joachim Henke
Many people have contributed improvements or reported bugs.
Most of these people are mentioned in the file THANKS.
The translations of the command line tools and man pages have been
contributed by many people via the Translation Project:
- https://translationproject.org/domain/xz.html
- https://translationproject.org/domain/xz-man.html
The authors of the translated man pages are in the header comments
of the man page files. In the source package, the authors of the
translations are in po/*.po and po4a/*.po files.
Third-party code whose authors aren't listed here:
- GNU getopt_long() in the 'lib' directory is included for
platforms that don't have a usable getopt_long().
- The build system files from GNU Autoconf, GNU Automake,
GNU Libtool, GNU Gettext, Autoconf Archive, and related files.

2146
CMakeLists.txt Normal file

File diff suppressed because it is too large Load Diff

105
COPYING
View File

@ -6,60 +6,95 @@ XZ Utils Licensing
is a rough summary of which licenses apply to which parts of this
package (but check the individual files to be sure!):
- liblzma is in the public domain.
- liblzma is under the BSD Zero Clause License (0BSD).
- xz, xzdec, and lzmadec command line tools are in the public
domain unless GNU getopt_long had to be compiled and linked
in from the lib directory. The getopt_long code is under
GNU LGPLv2.1+.
- The command line tools xz, xzdec, lzmadec, and lzmainfo are
under 0BSD except that, on systems that don't have a usable
getopt_long, GNU getopt_long is compiled and linked in from the
'lib' directory. The getopt_long code is under GNU LGPLv2.1+.
- The scripts to grep, diff, and view compressed files have been
adapted from gzip. These scripts and their documentation are
under GNU GPLv2+.
adapted from GNU gzip. These scripts (xzgrep, xzdiff, xzless,
and xzmore) are under GNU GPLv2+. The man pages of the scripts
are under 0BSD; they aren't based on the man pages of GNU gzip.
- All the documentation in the doc directory and most of the
XZ Utils specific documentation files in other directories
are in the public domain.
- Most of the XZ Utils specific documentation that is in
plain text files (like README, INSTALL, PACKAGERS, NEWS,
and ChangeLog) are under 0BSD unless stated otherwise in
the file itself. The files xz-file-format.txt and
lzma-file-format.xt are in the public domain but may
be distributed under the terms of 0BSD too.
- Translated messages are in the public domain.
- Doxygen-generated HTML version of the liblzma API documentation:
While Doxygen is under the GNU GPLv2, the license information
in Doxygen includes the following exception:
- The build system contains public domain files, and files that
are under GNU GPLv2+ or GNU GPLv3+. None of these files end up
in the binaries being built.
Documents produced by doxygen are derivative works
derived from the input used in their production;
they are not affected by this license.
- Test files and test code in the tests directory, and debugging
utilities in the debug directory are in the public domain.
Note: The JavaScript files (under the MIT license) have
been removed from the Doxygen output.
- The extra directory may contain public domain files, and files
that are under various free software licenses.
- The XZ logo (xz-logo.png) included in the Doxygen-generated
documentation is under the Creative Commons BY-SA 4.0 license.
You can do whatever you want with the files that have been put into
the public domain. If you find public domain legally problematic,
take the previous sentence as a license grant. If you still find
the lack of copyright legally problematic, you have too many
lawyers.
- Translated messages and man pages are under 0BSD except that
some old translations are in the public domain.
As usual, this software is provided "as is", without any warranty.
- Test files and test code in the 'tests' directory, and
debugging utilities in the 'debug' directory are under
the BSD Zero Clause License (0BSD).
If you copy significant amounts of public domain code from XZ Utils
- The GNU Autotools based build system contains files that are
under GNU GPLv2+, GNU GPLv3+, and a few permissive licenses.
These files don't affect the licensing of the binaries being
built.
- The extra directory contain files that are under various
free software licenses.
For the files under the BSD Zero Clause License (0BSD), if
a copyright notice is needed, the following is sufficient:
Copyright (C) The XZ Utils authors and contributors
If you copy significant amounts of 0BSD-licensed code from XZ Utils
into your project, acknowledging this somewhere in your software is
polite (especially if it is proprietary, non-free software), but
naturally it is not legally required. Here is an example of a good
notice to put into "about box" or into documentation:
it is not legally required by the license terms. Here is an example
of a good notice to put into "about box" or into documentation:
This software includes code from XZ Utils <http://tukaani.org/xz/>.
This software includes code from XZ Utils
<https://xz.tukaani.org/xz-utils/>.
The following license texts are included in the following files:
- COPYING.0BSD: BSD Zero Clause License
- COPYING.LGPLv2.1: GNU Lesser General Public License version 2.1
- COPYING.GPLv2: GNU General Public License version 2
- COPYING.GPLv3: GNU General Public License version 3
- COPYING.CC-BY-SA-4.0: Creative Commons Attribution-ShareAlike 4.0
International Public License
Note that the toolchain (compiler, linker etc.) may add some code
pieces that are copyrighted. Thus, it is possible that e.g. liblzma
binary wouldn't actually be in the public domain in its entirety
even though it contains no copyrighted code from the XZ Utils source
package.
A note about old XZ Utils releases:
If you have questions, don't hesitate to ask the author(s) for more
information.
XZ Utils releases 5.4.6 and older and 5.5.1alpha have a
significant amount of code put into the public domain and
that obviously remains so. The switch from public domain to
0BSD for newer releases was made in Febrary 2024 because
public domain has (real or perceived) legal ambiguities in
some jurisdictions.
There is very little *practical* difference between public
domain and 0BSD. The main difference likely is that one
shouldn't claim that 0BSD-licensed code is in the public
domain; 0BSD-licensed code is copyrighted but available under
an extremely permissive license. Neither 0BSD nor public domain
require retaining or reproducing author, copyright holder, or
license notices when distributing the software. (Compare to,
for example, BSD 2-Clause "Simplified" License which does have
such requirements.)
If you have questions, don't hesitate to ask for more information.
The contact information is in the README file.

11
COPYING.0BSD Normal file
View File

@ -0,0 +1,11 @@
Permission to use, copy, modify, and/or distribute this
software for any purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

427
COPYING.CC-BY-SA-4.0 Normal file
View File

@ -0,0 +1,427 @@
Attribution-ShareAlike 4.0 International
=======================================================================
Creative Commons Corporation ("Creative Commons") is not a law firm and
does not provide legal services or legal advice. Distribution of
Creative Commons public licenses does not create a lawyer-client or
other relationship. Creative Commons makes its licenses and related
information available on an "as-is" basis. Creative Commons gives no
warranties regarding its licenses, any material licensed under their
terms and conditions, or any related information. Creative Commons
disclaims all liability for damages resulting from their use to the
fullest extent possible.
Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and
conditions that creators and other rights holders may use to share
original works of authorship and other material subject to copyright
and certain other rights specified in the public license below. The
following considerations are for informational purposes only, are not
exhaustive, and do not form part of our licenses.
Considerations for licensors: Our public licenses are
intended for use by those authorized to give the public
permission to use material in ways otherwise restricted by
copyright and certain other rights. Our licenses are
irrevocable. Licensors should read and understand the terms
and conditions of the license they choose before applying it.
Licensors should also secure all rights necessary before
applying our licenses so that the public can reuse the
material as expected. Licensors should clearly mark any
material not subject to the license. This includes other CC-
licensed material, or material used under an exception or
limitation to copyright. More considerations for licensors:
wiki.creativecommons.org/Considerations_for_licensors
Considerations for the public: By using one of our public
licenses, a licensor grants the public permission to use the
licensed material under specified terms and conditions. If
the licensor's permission is not necessary for any reason--for
example, because of any applicable exception or limitation to
copyright--then that use is not regulated by the license. Our
licenses grant only permissions under copyright and certain
other rights that a licensor has authority to grant. Use of
the licensed material may still be restricted for other
reasons, including because others have copyright or other
rights in the material. A licensor may make special requests,
such as asking that all changes be marked or described.
Although not required by our licenses, you are encouraged to
respect those requests where reasonable. More considerations
for the public:
wiki.creativecommons.org/Considerations_for_licensees
=======================================================================
Creative Commons Attribution-ShareAlike 4.0 International Public
License
By exercising the Licensed Rights (defined below), You accept and agree
to be bound by the terms and conditions of this Creative Commons
Attribution-ShareAlike 4.0 International Public License ("Public
License"). To the extent this Public License may be interpreted as a
contract, You are granted the Licensed Rights in consideration of Your
acceptance of these terms and conditions, and the Licensor grants You
such rights in consideration of benefits the Licensor receives from
making the Licensed Material available under these terms and
conditions.
Section 1 -- Definitions.
a. Adapted Material means material subject to Copyright and Similar
Rights that is derived from or based upon the Licensed Material
and in which the Licensed Material is translated, altered,
arranged, transformed, or otherwise modified in a manner requiring
permission under the Copyright and Similar Rights held by the
Licensor. For purposes of this Public License, where the Licensed
Material is a musical work, performance, or sound recording,
Adapted Material is always produced where the Licensed Material is
synched in timed relation with a moving image.
b. Adapter's License means the license You apply to Your Copyright
and Similar Rights in Your contributions to Adapted Material in
accordance with the terms and conditions of this Public License.
c. BY-SA Compatible License means a license listed at
creativecommons.org/compatiblelicenses, approved by Creative
Commons as essentially the equivalent of this Public License.
d. Copyright and Similar Rights means copyright and/or similar rights
closely related to copyright including, without limitation,
performance, broadcast, sound recording, and Sui Generis Database
Rights, without regard to how the rights are labeled or
categorized. For purposes of this Public License, the rights
specified in Section 2(b)(1)-(2) are not Copyright and Similar
Rights.
e. Effective Technological Measures means those measures that, in the
absence of proper authority, may not be circumvented under laws
fulfilling obligations under Article 11 of the WIPO Copyright
Treaty adopted on December 20, 1996, and/or similar international
agreements.
f. Exceptions and Limitations means fair use, fair dealing, and/or
any other exception or limitation to Copyright and Similar Rights
that applies to Your use of the Licensed Material.
g. License Elements means the license attributes listed in the name
of a Creative Commons Public License. The License Elements of this
Public License are Attribution and ShareAlike.
h. Licensed Material means the artistic or literary work, database,
or other material to which the Licensor applied this Public
License.
i. Licensed Rights means the rights granted to You subject to the
terms and conditions of this Public License, which are limited to
all Copyright and Similar Rights that apply to Your use of the
Licensed Material and that the Licensor has authority to license.
j. Licensor means the individual(s) or entity(ies) granting rights
under this Public License.
k. Share means to provide material to the public by any means or
process that requires permission under the Licensed Rights, such
as reproduction, public display, public performance, distribution,
dissemination, communication, or importation, and to make material
available to the public including in ways that members of the
public may access the material from a place and at a time
individually chosen by them.
l. Sui Generis Database Rights means rights other than copyright
resulting from Directive 96/9/EC of the European Parliament and of
the Council of 11 March 1996 on the legal protection of databases,
as amended and/or succeeded, as well as other essentially
equivalent rights anywhere in the world.
m. You means the individual or entity exercising the Licensed Rights
under this Public License. Your has a corresponding meaning.
Section 2 -- Scope.
a. License grant.
1. Subject to the terms and conditions of this Public License,
the Licensor hereby grants You a worldwide, royalty-free,
non-sublicensable, non-exclusive, irrevocable license to
exercise the Licensed Rights in the Licensed Material to:
a. reproduce and Share the Licensed Material, in whole or
in part; and
b. produce, reproduce, and Share Adapted Material.
2. Exceptions and Limitations. For the avoidance of doubt, where
Exceptions and Limitations apply to Your use, this Public
License does not apply, and You do not need to comply with
its terms and conditions.
3. Term. The term of this Public License is specified in Section
6(a).
4. Media and formats; technical modifications allowed. The
Licensor authorizes You to exercise the Licensed Rights in
all media and formats whether now known or hereafter created,
and to make technical modifications necessary to do so. The
Licensor waives and/or agrees not to assert any right or
authority to forbid You from making technical modifications
necessary to exercise the Licensed Rights, including
technical modifications necessary to circumvent Effective
Technological Measures. For purposes of this Public License,
simply making modifications authorized by this Section 2(a)
(4) never produces Adapted Material.
5. Downstream recipients.
a. Offer from the Licensor -- Licensed Material. Every
recipient of the Licensed Material automatically
receives an offer from the Licensor to exercise the
Licensed Rights under the terms and conditions of this
Public License.
b. Additional offer from the Licensor -- Adapted Material.
Every recipient of Adapted Material from You
automatically receives an offer from the Licensor to
exercise the Licensed Rights in the Adapted Material
under the conditions of the Adapter's License You apply.
c. No downstream restrictions. You may not offer or impose
any additional or different terms or conditions on, or
apply any Effective Technological Measures to, the
Licensed Material if doing so restricts exercise of the
Licensed Rights by any recipient of the Licensed
Material.
6. No endorsement. Nothing in this Public License constitutes or
may be construed as permission to assert or imply that You
are, or that Your use of the Licensed Material is, connected
with, or sponsored, endorsed, or granted official status by,
the Licensor or others designated to receive attribution as
provided in Section 3(a)(1)(A)(i).
b. Other rights.
1. Moral rights, such as the right of integrity, are not
licensed under this Public License, nor are publicity,
privacy, and/or other similar personality rights; however, to
the extent possible, the Licensor waives and/or agrees not to
assert any such rights held by the Licensor to the limited
extent necessary to allow You to exercise the Licensed
Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this
Public License.
3. To the extent possible, the Licensor waives any right to
collect royalties from You for the exercise of the Licensed
Rights, whether directly or through a collecting society
under any voluntary or waivable statutory or compulsory
licensing scheme. In all other cases the Licensor expressly
reserves any right to collect such royalties.
Section 3 -- License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the
following conditions.
a. Attribution.
1. If You Share the Licensed Material (including in modified
form), You must:
a. retain the following if it is supplied by the Licensor
with the Licensed Material:
i. identification of the creator(s) of the Licensed
Material and any others designated to receive
attribution, in any reasonable manner requested by
the Licensor (including by pseudonym if
designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of
warranties;
v. a URI or hyperlink to the Licensed Material to the
extent reasonably practicable;
b. indicate if You modified the Licensed Material and
retain an indication of any previous modifications; and
c. indicate the Licensed Material is licensed under this
Public License, and include the text of, or the URI or
hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any
reasonable manner based on the medium, means, and context in
which You Share the Licensed Material. For example, it may be
reasonable to satisfy the conditions by providing a URI or
hyperlink to a resource that includes the required
information.
3. If requested by the Licensor, You must remove any of the
information required by Section 3(a)(1)(A) to the extent
reasonably practicable.
b. ShareAlike.
In addition to the conditions in Section 3(a), if You Share
Adapted Material You produce, the following conditions also apply.
1. The Adapter's License You apply must be a Creative Commons
license with the same License Elements, this version or
later, or a BY-SA Compatible License.
2. You must include the text of, or the URI or hyperlink to, the
Adapter's License You apply. You may satisfy this condition
in any reasonable manner based on the medium, means, and
context in which You Share Adapted Material.
3. You may not offer or impose any additional or different terms
or conditions on, or apply any Effective Technological
Measures to, Adapted Material that restrict exercise of the
rights granted under the Adapter's License You apply.
Section 4 -- Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that
apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
to extract, reuse, reproduce, and Share all or a substantial
portion of the contents of the database;
b. if You include all or a substantial portion of the database
contents in a database in which You have Sui Generis Database
Rights, then the database in which You have Sui Generis Database
Rights (but not its individual contents) is Adapted Material,
including for purposes of Section 3(b); and
c. You must comply with the conditions in Section 3(a) if You Share
all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not
replace Your obligations under this Public License where the Licensed
Rights include other Copyright and Similar Rights.
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
c. The disclaimer of warranties and limitation of liability provided
above shall be interpreted in a manner that, to the extent
possible, most closely approximates an absolute disclaimer and
waiver of all liability.
Section 6 -- Term and Termination.
a. This Public License applies for the term of the Copyright and
Similar Rights licensed here. However, if You fail to comply with
this Public License, then Your rights under this Public License
terminate automatically.
b. Where Your right to use the Licensed Material has terminated under
Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided
it is cured within 30 days of Your discovery of the
violation; or
2. upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any
right the Licensor may have to seek remedies for Your violations
of this Public License.
c. For the avoidance of doubt, the Licensor may also offer the
Licensed Material under separate terms or conditions or stop
distributing the Licensed Material at any time; however, doing so
will not terminate this Public License.
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
License.
Section 7 -- Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different
terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the
Licensed Material not stated herein are separate from and
independent of the terms and conditions of this Public License.
Section 8 -- Interpretation.
a. For the avoidance of doubt, this Public License does not, and
shall not be interpreted to, reduce, limit, restrict, or impose
conditions on any use of the Licensed Material that could lawfully
be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is
deemed unenforceable, it shall be automatically reformed to the
minimum extent necessary to make it enforceable. If the provision
cannot be reformed, it shall be severed from this Public License
without affecting the enforceability of the remaining terms and
conditions.
c. No term or condition of this Public License will be waived and no
failure to comply consented to unless expressly agreed to by the
Licensor.
d. Nothing in this Public License constitutes or may be interpreted
as a limitation upon, or waiver of, any privileges and immunities
that apply to the Licensor or You, including from the legal
processes of any jurisdiction or authority.
=======================================================================
Creative Commons is not a party to its public
licenses. Notwithstanding, Creative Commons may elect to apply one of
its public licenses to material it publishes and in those instances
will be considered the “Licensor.” The text of the Creative Commons
public licenses is dedicated to the public domain under the CC0 Public
Domain Dedication. Except for the limited purpose of indicating that
material is shared under a Creative Commons public license or as
otherwise permitted by the Creative Commons policies published at
creativecommons.org/policies, Creative Commons does not authorize the
use of the trademark "Creative Commons" or any other trademark or logo
of Creative Commons without its prior written consent including,
without limitation, in connection with any unauthorized modifications
to any of its public licenses or any other arrangements,
understandings, or agreements concerning use of licensed material. For
the avoidance of doubt, this paragraph does not form part of the
public licenses.
Creative Commons may be contacted at creativecommons.org.

View File

@ -1,12 +1,12 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
@ -56,7 +56,7 @@ patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it

View File

@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -1,5 +1,5 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@ -10,7 +10,7 @@
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
@ -112,7 +112,7 @@ modification follow. Pay close attention to the difference between a
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
@ -146,7 +146,7 @@ such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
@ -432,7 +432,7 @@ decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
@ -455,7 +455,7 @@ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
@ -500,5 +500,3 @@ necessary. Here is a sample; alter the names:
Ty Coon, President of Vice
That's all there is to it!

View File

@ -1,6 +1,6 @@
See the commit log in the git repository:
git clone http://git.tukaani.org/xz.git
git clone https://github.com/tukaani-project/xz
Note that "make dist" doesn't put this tiny file into the package.
Instead, the git commit log is used as ChangeLog. See dist-hook in

File diff suppressed because it is too large Load Diff

583
INSTALL
View File

@ -6,12 +6,15 @@ XZ Utils Installation
1. Supported platforms
1.1. Compilers
1.2. Platform-specific notes
1.2.1. IRIX
1.2.2. MINIX 3
1.2.3. OpenVMS
1.2.4. Tru64
1.2.5. Windows
1.2.6. DOS
1.2.1. AIX
1.2.2. IRIX
1.2.3. MINIX 3
1.2.4. OpenVMS
1.2.5. Solaris, OpenSolaris, and derivatives
1.2.6. Tru64
1.2.7. Windows
1.2.8. DOS
1.2.9. z/OS
1.3. Adding support for new platforms
2. configure options
2.1. Static vs. dynamic linking of liblzma
@ -19,11 +22,16 @@ XZ Utils Installation
3. xzgrep and other scripts
3.1. Dependencies
3.2. PATH
4. Troubleshooting
4.1. "No C99 compiler was found."
4.2. "No POSIX conforming shell (sh) was found."
4.3. configure works but build fails at crc32_x86.S
4.4. Lots of warnings about symbol visibility
4. Tests
4.1 Testing in parallel
4.2 Cross compiling
5. Troubleshooting
5.1. "No C99 compiler was found."
5.2. "No POSIX conforming shell (sh) was found."
5.3. configure works but build fails at crc32_x86.S
5.4. Lots of warnings about symbol visibility
5.5. "make check" fails
5.6. liblzma.so (or similar) not found when running xz
0. Preface
@ -62,31 +70,44 @@ XZ Utils Installation
1.2. Platform-specific notes
1.2.1. IRIX
1.2.1. AIX
If you use IBM XL C compiler, pass CC=xlc_r to configure. If
you use CC=xlc instead, you must disable threading support
with --disable-threads (usually not recommended).
1.2.2. IRIX
MIPSpro 7.4.4m has been reported to produce broken code if using
the -O2 optimization flag ("make check" fails). Using -O1 should
work.
A problem has been reported when using shared liblzma. Passing
--disable-shared to configure works around this. Alternatively,
putting "-64" to CFLAGS to build a 64-bit version might help too.
1.2.2. MINIX 3
1.2.3. MINIX 3
The default install of MINIX 3 includes Amsterdam Compiler Kit (ACK),
which doesn't support C99. Install GCC to compile XZ Utils.
MINIX 3.1.8 (and possibly some other versions too) has bugs in
/usr/include/stdint.h, which has to be patched before XZ Utils
can be compiled correctly. See
MINIX 3.1.8 and older have bugs in /usr/include/stdint.h, which has
to be patched before XZ Utils can be compiled correctly. See
<http://gforge.cs.vu.nl/gf/project/minix/tracker/?action=TrackerItemEdit&tracker_item_id=537>.
MINIX 3.2.0 and later use a different libc and aren't affected by
the above bug.
XZ Utils doesn't have code to detect the amount of physical RAM and
number of CPU cores on MINIX 3.
See section 4.4 in this file about symbol visibility warnings (you
See section 5.4 in this file about symbol visibility warnings (you
may want to pass gl_cv_cc_visibility=no to configure).
1.2.3. OpenVMS
1.2.4. OpenVMS
XZ Utils can be built for OpenVMS, but the build system files
are not included in the XZ Utils source package. The required
@ -96,41 +117,92 @@ XZ Utils Installation
http://nchrem.tnw.tudelft.nl/openvms/software2.html#xzutils
1.2.4. Tru64
1.2.5. Solaris, OpenSolaris, and derivatives
The following linker error has been reported on some x86 systems:
ld: fatal: relocation error: R_386_GOTOFF: ...
This can be worked around by passing gl_cv_cc_visibility=no
as an argument to the configure script.
test_scripts.sh in "make check" may fail if good enough tools are
missing from PATH (/usr/xpg4/bin or /usr/xpg6/bin). Nowadays
/usr/xpg4/bin is added to the script PATH by default on Solaris
(see --enable-path-for-scripts=PREFIX in section 2), but old xz
releases needed extra steps. See sections 5.5 and 3.2 for more
information.
1.2.6. Tru64
If you try to use the native C compiler on Tru64 (passing CC=cc to
configure), you may need the workaround mention in section 4.1 in
configure), you may need the workaround mention in section 5.1 in
this file (pass also ac_cv_prog_cc_c99= to configure).
1.2.5. Windows
1.2.7. Windows
Building XZ Utils on Windows is supported under MinGW + MSYS,
MinGW-w64 + MSYS, and Cygwin. There is windows/build.bash to
ease packaging XZ Utils with MinGW(-w64) + MSYS into a
redistributable .zip or .7z file. See windows/INSTALL-Windows.txt
for more information.
The "windows" directory contains instructions for a few types
of builds:
It might be possible to build liblzma with a non-GNU toolchain too,
but that will probably require writing a separate makefile. Building
the command line tools with non-GNU toolchains will be harder than
building only liblzma.
- INSTALL-MinGW-w64_with_CMake.txt
Simple instructions how to build XZ Utils natively on
Windows using only CMake and a prebuilt toolchain
(GCC + MinGW-w64 or Clang/LLVM + MinGW-w64).
Even if liblzma is built with MinGW, the resulting DLL or static
library can be used by other compilers and linkers, including MSVC.
Thus, it shouldn't be a problem to use MinGW to build liblzma even
if you cannot use MinGW to build the rest of your project. See
windows/README-Windows.txt for details.
- INSTALL-MinGW-w64_with_Autotools.txt
Native build under MSYS2 or cross-compilation from
GNU/Linux using a bash script that creates a .zip
and .7z archives of the binaries and documentation.
The related file README-Windows.txt is for the
resulting binary package.
- INSTALL-MSVC.txt
Building with MSVC / Visual Studio and CMake.
- liblzma-crt-mixing.txt
Documentation what to take into account as a programmer
if liblzma.dll and the application don't use the same
CRT (MSVCRT or UCRT).
Other choices:
- Cygwin: https://cygwin.com/
Building on Cygwin can be done like on many POSIX operating
systems. XZ Utils >= 5.2.0 isn't compatible with Cygwin older
than 1.7.35 (data loss!). 1.7.35 was released on 2015-03-04.
- MSYS2: https://www.msys2.org/
1.2.6. DOS
1.2.8. DOS
There is an experimental Makefile in the "dos" directory to build
XZ Utils on DOS using DJGPP. Support for long file names (LFN) is
needed. See dos/README for more information.
There is a Makefile in the "dos" directory to build XZ Utils on
DOS using DJGPP. Support for long file names (LFN) is needed at
build time but the resulting xz.exe works without LFN support too.
See dos/INSTALL.txt and dos/README.txt for more information.
GNU Autotools based build hasn't been tried on DOS. If you try, I
would like to hear if it worked.
1.2.9. z/OS
To build XZ Utils on z/OS UNIX System Services using xlc, pass
these options to the configure script: CC='xlc -qhaltonmsg=CCN3296'
CPPFLAS='-D_UNIX03_THREADS -D_XOPEN_SOURCE=600'. The first makes
xlc throw an error if a header file is missing, which is required
to make the tests in configure work. The CPPFLAGS are needed to
get pthread support (some other CPPFLAGS may work too; if there
are problems, try -D_UNIX95_THREADS instead of -D_UNIX03_THREADS).
test_scripts.sh in "make check" will fail even if the scripts
actually work because the test data includes compressed files
with US-ASCII text.
No other tests should fail. If test_files.sh fails, check that
the included .xz test files weren't affected by EBCDIC conversion.
XZ Utils doesn't have code to detect the amount of physical RAM and
number of CPU cores on z/OS.
1.3. Adding support for new platforms
@ -203,6 +275,54 @@ XZ Utils Installation
the liblzma ABI, so this option should be used only when
it is known to not cause problems.
--enable-external-sha256
Try to use SHA-256 code from the operating system libc
or similar base system libraries. This doesn't try to
use OpenSSL or libgcrypt or such libraries.
The reasons to use this option:
- It makes liblzma slightly smaller.
- It might improve SHA-256 speed if the implementation
in the operating is very good (but see below).
External SHA-256 is disabled by default for two reasons:
- On some operating systems the symbol names of the
SHA-256 functions conflict with OpenSSL's libcrypto.
This causes weird problems such as decompression
errors if an application is linked against both
liblzma and libcrypto. This problem affects at least
FreeBSD 10 and older and MINIX 3.3.0 and older, but
other OSes that provide a function "SHA256_Init" might
also be affected. FreeBSD 11 has the problem fixed.
NetBSD had the problem but it was fixed it in 2009
already. OpenBSD uses "SHA256Init" and thus never had
a conflict with libcrypto.
- The SHA-256 code in liblzma is faster than the SHA-256
code provided by some operating systems. If you are
curious, build two copies of xz (internal and external
SHA-256) and compare the decompression (xz --test)
times:
dd if=/dev/zero bs=1024k count=1024 \
| xz -v -0 -Csha256 > foo.xz
time xz --test foo.xz
--disable-microlzma
Don't build MicroLZMA encoder and decoder. This omits
lzma_microlzma_encoder() and lzma_microlzma_decoder()
API functions from liblzma. These functions are needed
by specific applications only. They were written for
erofs-utils but they may be used by others too.
--disable-lzip-decoder
Disable decompression support for .lz (lzip) files.
This omits the API function lzma_lzip_decoder() from
liblzma and .lz support from the xz tool.
--disable-xz
--disable-xzdec
--disable-lzmadec
@ -226,29 +346,109 @@ XZ Utils Installation
Don't install the scripts xzdiff, xzgrep, xzmore, xzless,
and their symlinks.
--disable-assembler
liblzma includes some assembler optimizations. Currently
there is only assembler code for CRC32 and CRC64 for
32-bit x86.
--disable-doc
Don't install the documentation files to $docdir
(often /usr/doc/xz or /usr/local/doc/xz). Man pages
will still be installed. The $docdir can be changed
with --docdir=DIR.
All the assembler code in liblzma is position-independent
code, which is suitable for use in shared libraries and
position-independent executables. So far only i386
instructions are used, but the code is optimized for i686
class CPUs. If you are compiling liblzma exclusively for
--disable-assembler
This disables CRC32 and CRC64 assembly code on
32-bit x86. This option currently does nothing
on other architectures (not even on x86-64).
The 32-bit x86 assembly is position-independent code
which is suitable for use in shared libraries and
position-independent executables. It uses only i386
instructions but the code is optimized for i686 class
CPUs. If you are compiling liblzma exclusively for
pre-i686 systems, you may want to disable the assembler
code.
--enable-unaligned-access
Allow liblzma to use unaligned memory access for 16-bit
and 32-bit loads and stores. This should be enabled only
when the hardware supports this, i.e. when unaligned
access is fast. Some operating system kernels emulate
unaligned access, which is extremely slow. This option
shouldn't be used on systems that rely on such emulation.
--disable-clmul-crc
Disable the use of carryless multiplication for CRC
calculation even if compiler support for it is detected.
The code uses runtime detection of SSSE3, SSE4.1, and
CLMUL instructions on x86. On 32-bit x86 this currently
is used only if --disable-assembler is used (this might
be fixed in the future). The code works on E2K too.
Unaligned access is enabled by default on x86, x86-64,
and big endian PowerPC.
If using compiler options that unconditionally allow the
required extensions (-msse4.1 -mpclmul) then runtime
detection isn't used and the generic code is omitted.
--disable-arm64-crc32
Disable the use of the ARM64 CRC32 instruction extension
even if compiler support for it is detected. The code will
detect support for the instruction at runtime.
If using compiler options that unconditionally allow the
required extensions (-march=armv8-a+crc or -march=armv8.1-a
and later) then runtime detection isn't used and the
generic code is omitted.
--enable-unaligned-access
Allow liblzma to use unaligned memory access for 16-bit,
32-bit, and 64-bit loads and stores. This should be
enabled only when the hardware supports this, that is,
when unaligned access is fast. Some operating system
kernels emulate unaligned access, which is extremely
slow. This option shouldn't be used on systems that
rely on such emulation.
Unaligned access is enabled by default on these:
- 32-bit x86
- 64-bit x86-64
- 32-bit big endian PowerPC
- 64-bit big endian PowerPC
- 64-bit little endian PowerPC
- some RISC-V [1]
- some 32-bit ARM [2]
- some 64-bit ARM64 [2] (NOTE: Autodetection bug
if using GCC -mstrict-align, see below.)
[1] Unaligned access is enabled by default if
configure sees that the C compiler
#defines __riscv_misaligned_fast.
[2] Unaligned access is enabled by default if
configure sees that the C compiler
#defines __ARM_FEATURE_UNALIGNED:
- ARMv7 + GCC or Clang: It works. The options
-munaligned-access and -mno-unaligned-access
affect this macro correctly.
- ARM64 + Clang: It works. The options
-munaligned-access, -mno-unaligned-access,
and -mstrict-align affect this macro correctly.
Clang >= 17 supports -mno-strict-align too.
- ARM64 + GCC: It partially works. The macro
is always #defined by GCC versions at least
up to 13.2, even when using -mstrict-align.
If building for strict-align ARM64, the
configure option --disable-unaligned-access
should be used if using a GCC version that has
this issue because otherwise the performance
may be degraded. It likely won't crash due to
how unaligned access is done in the C code.
--enable-unsafe-type-punning
This enables use of code like
uint8_t *buf8 = ...;
*(uint32_t *)buf8 = ...;
which violates strict aliasing rules and may result
in broken code. There should be no need to use this
option with recent GCC or Clang versions on any
arch as just as fast code can be generated in a safe
way too (using __builtin_assume_aligned + memcpy).
However, this option might improve performance in some
other cases, especially with old compilers (for example,
GCC 3 and early 4.x on x86, GCC < 6 on ARMv6 and ARMv7).
--enable-small
Reduce the size of liblzma by selecting smaller but
@ -282,16 +482,124 @@ XZ Utils Installation
the amount of RAM on the operating system you use. See
src/common/tuklib_physmem.c for details.
--disable-threads
Disable threading support. This makes some things
thread-unsafe, meaning that if multithreaded application
calls liblzma functions from more than one thread,
something bad may happen.
--enable-threads=METHOD
Threading support is enabled by default so normally there
is no need to specify this option.
Use this option if threading support causes you trouble,
or if you know that you will use liblzma only from
single-threaded applications and want to avoid dependency
on libpthread.
Supported values for METHOD:
yes Autodetect the threading method. If none
is found, configure will give an error.
posix Use POSIX pthreads. This is the default
except on Windows outside Cygwin.
win95 Use Windows 95 compatible threads. This
is compatible with Windows XP and later
too. This is the default for 32-bit x86
Windows builds. Unless the compiler
supports __attribute__((__constructor__)),
the 'win95' threading is incompatible with
--enable-small.
vista Use Windows Vista compatible threads. The
resulting binaries won't run on Windows XP
or older. This is the default for Windows
excluding 32-bit x86 builds (that is, on
x86-64 the default is 'vista').
no Disable threading support. This is the
same as using --disable-threads.
NOTE: If combined with --enable-small
and the compiler doesn't support
__attribute__((__constructor__)), the
resulting liblzma won't be thread safe,
that is, if a multi-threaded application
calls any liblzma functions from more than
one thread, something bad may happen.
--enable-ifunc
Use __attribute__((__ifunc__())) in liblzma. This is
enabled by default on GNU/Linux and FreeBSD.
The ifunc attribute is incompatible with
-fsanitize=address. --disable-ifunc must be used
if any -fsanitize= option is specified in CFLAGS.
--enable-sandbox=METHOD
There is limited sandboxing support in the xz and xzdec
tools. If built with sandbox support, xz uses it
automatically when (de)compressing exactly one file to
standard output when the options --files or --files0 aren't
used. This is a common use case, for example,
(de)compressing .tar.xz files via GNU tar. The sandbox is
also used for single-file 'xz --test' or 'xz --list'.
xzdec always uses the sandbox, except when more than one
file are decompressed. In this case it will enable the
sandbox for the last file that is decompressed.
Supported METHODs:
auto Look for a supported sandboxing method
and use it if found. If no method is
found, then sandboxing isn't used.
This is the default.
no Disable sandboxing support.
capsicum
Use Capsicum (FreeBSD >= 10.2) for
sandboxing. If no Capsicum support
is found, configure will give an error.
pledge Use pledge(2) (OpenBSD >= 5.9) for
sandboxing. If pledge(2) isn't found,
configure will give an error.
landlock
Use Landlock (Linux >= 5.13) for
sandboxing. If no Landlock support
is found, configure will give an error.
--enable-symbol-versions[=VARIANT]
Use symbol versioning for liblzma shared library.
This is enabled by default on GNU/Linux (glibc only),
other GNU-based systems, and FreeBSD.
Symbol versioning is never used for static liblzma. This
option is ignored when not building a shared library.
Supported VARIANTs:
no Disable symbol versioning. This is the
same as using --disable-symbol-versions.
auto Autodetect between "no", "linux",
and "generic".
yes Autodetect between "linux" and
"generic". This forces symbol
versioning to be used when
building a shared library.
generic Generic version is the default for
FreeBSD and GNU/Linux on MicroBlaze.
This is also used on GNU/Linux when
building with NVIDIA HPC Compiler
because the compiler doesn't support
the features required for the "linux"
variant below.
linux Special version for GNU/Linux (glibc
only). This adds a few extra symbol
versions for compatibility with binaries
that have been linked against a liblzma
version that has been patched with
"xz-5.2.2-compat-libs.patch" from
RHEL/CentOS 7. That patch was used
by some build tools outside of
RHEL/CentOS 7 too.
--enable-debug
This enables the assert() macro and possibly some other
@ -304,6 +612,23 @@ XZ Utils Installation
and should work on most systems. This has no effect on the
resulting binaries.
--enable-path-for-scripts=PREFIX
If PREFIX isn't empty, PATH=PREFIX:$PATH will be set in
the beginning of the scripts (xzgrep and others).
The default is empty except on Solaris the default is
/usr/xpg4/bin.
This can be useful if the default PATH doesn't contain
modern POSIX tools (as can be the case on Solaris) or if
one wants to ensure that the correct xz binary is in the
PATH for the scripts. Note that the latter use can break
"make check" if the prefixed PATH causes a wrong xz binary
(other than the one that was just built) to be used.
Older xz releases support a different method for setting
the PATH for the scripts. It is described in section 3.2
and is supported in this xz version too.
2.1. Static vs. dynamic linking of liblzma
@ -333,7 +658,7 @@ XZ Utils Installation
liblzma, pass --enable-small to configure.
- Tell the compiler to optimize for size instead of speed.
E.g. with GCC, put -Os into CFLAGS.
For example, with GCC, put -Os into CFLAGS.
- xzdec and lzmadec will never use multithreading capabilities of
liblzma. You can avoid dependency on libpthread by passing
@ -362,20 +687,31 @@ XZ Utils Installation
gl_cv_posix_shell=/path/to/posix-sh as an argument to the configure
script.
Some of the scripts require also mktemp. The original mktemp can be
found from <http://www.mktemp.org/>. On GNU, most will use the mktemp
program from GNU coreutils instead of the original implementation.
Both mktemp versions are fine for XZ Utils (and practically for
everything else too).
xzdiff (xzcmp/lzdiff/lzcmp) may use mktemp if it is available. As
a fallback xzdiff will use mkdir to securely create a temporary
directory. Having mktemp available is still recommended since the
mkdir fallback method isn't as robust as mktemp is. The original
mktemp can be found from <https://www.mktemp.org/>. On GNU, most will
use the mktemp program from GNU coreutils instead of the original
implementation. Both mktemp versions are fine.
In addition to using xz to decompress .xz files, xzgrep and xzdiff
use gzip, bzip2, and lzop to support .gz, bz2, and .lzo files.
3.2. PATH
The method described below is supported by older xz releases.
It is supported by the current version too, but the newer
--enable-path-for-scripts=PREFIX described in section 2 may be
more convenient.
The scripts assume that the required tools (standard POSIX utilities,
mktemp, and xz) are in PATH; the scripts don't set the PATH themselves.
Some people like this while some think this is a bug. Those in the
latter group can easily patch the scripts before running the configure
script by taking advantage of a placeholder line in the scripts.
mktemp, and xz) are in PATH; the scripts don't set the PATH themselves
(except as described for --enable-path-for-scripts=PREFIX). Some
people like this while some think this is a bug. Those in the latter
group can easily patch the scripts before running the configure script
by taking advantage of a placeholder line in the scripts.
For example, to make the scripts prefix /usr/bin:/bin to PATH:
@ -383,10 +719,54 @@ XZ Utils Installation
src/scripts/xz*.in
4. Troubleshooting
4. Tests
--------
The test framework can be built and run by executing "make check" in
the build directory. The tests are a mix of executables and POSIX
shell scripts (sh). All tests should pass if the default configuration
is used. Disabling features through the configure options may cause
some tests to be skipped. If any tests do not pass, see section 5.5.
4.1. Testing in parallel
The tests can be run in parallel using the "-j" make option on systems
that support it. For instance, "make -j4 check" will run up to four
tests simultaneously.
4.2. Cross compiling
The tests can be built without running them:
make check TESTS=
The TESTS variable is the list of tests you wish to run. Leaving it
empty will compile the tests without running any.
If the tests are copied to a target machine to execute, the test data
files in the directory tests/files must also be copied. The tests
search for the data files using the environment variable $srcdir,
expecting to find the data files under $srcdir/files/. If $srcdir
isn't set then it defaults to the current directory.
The shell script tests can be copied from the source directory to the
target machine to execute. In addition to the test files, these tests
will expect the following relative file paths to execute properly:
./create_compress_files
../config.h
../src/xz/xz
../src/xzdec/xzdec
../src/scripts/xzdiff
../src/scripts/xzgrep
5. Troubleshooting
------------------
4.1. "No C99 compiler was found."
5.1. "No C99 compiler was found."
You need a C99 compiler to build XZ Utils. If the configure script
cannot find a C99 compiler and you think you have such a compiler
@ -401,16 +781,17 @@ XZ Utils Installation
support enough C99.
4.2. "No POSIX conforming shell (sh) was found."
5.2. "No POSIX conforming shell (sh) was found."
xzgrep and other scripts need a shell that (roughly) conforms
to POSIX. The configure script tries to find such a shell. If
it fails, you can force the shell to be used by passing
gl_cv_posix_shell=/path/to/posix-sh as an argument to the configure
script.
script. Alternatively you can omit the installation of scripts and
this error by passing --disable-scripts to configure.
4.3. configure works but build fails at crc32_x86.S
5.3. configure works but build fails at crc32_x86.S
The easy fix is to pass --disable-assembler to the configure script.
@ -427,7 +808,7 @@ XZ Utils Installation
(see INSTALL.generic).
4.4. Lots of warnings about symbol visibility
5.4. Lots of warnings about symbol visibility
On some systems where symbol visibility isn't supported, GCC may
still accept the visibility options and attributes, which will make
@ -438,3 +819,37 @@ XZ Utils Installation
resulting binaries, but fewer warnings looks nicer and may allow
using --enable-werror.
5.5. "make check" fails
If the other tests pass but test_scripts.sh fails, then the problem
is in the scripts in src/scripts. Comparing the contents of
tests/xzgrep_test_output to tests/xzgrep_expected_output might
give a good idea about problems in xzgrep. One possibility is that
some tools are missing from the current PATH or the tools lack
support for some POSIX features. This can happen at least on
Solaris where the tools in /bin may be ancient but good enough
tools are available in /usr/xpg4/bin or /usr/xpg6/bin. For possible
fixes, see --enable-path-for-scripts=PREFIX in section 2 and the
older alternative method described in section 3.2 of this file.
If tests other than test_scripts.sh fail, a likely reason is that
libtool links the test programs against an installed version of
liblzma instead of the version that was just built. This is
obviously a bug which seems to happen on some platforms.
A workaround is to uninstall the old liblzma versions first.
If the problem isn't any of those described above, then it's likely
a bug in XZ Utils or in the compiler. See the platform-specific
notes in this file for possible known problems. Please report
a bug if you cannot solve the problem. See README for contact
information.
5.6. liblzma.so (or similar) not found when running xz
If you installed the package with "make install" and get an error
about liblzma.so (or a similarly named file) being missing, try
running "ldconfig" to update the run-time linker cache (if your
operating system has such a command).

View File

@ -1,8 +1,8 @@
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software
Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
@ -12,97 +12,96 @@ without warranty of any kind.
Basic Installation
==================
Briefly, the shell commands `./configure; make; make install' should
configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for
Briefly, the shell command './configure && make && make install'
should configure, build, and install this package. The following
more-detailed instructions are generic; see the 'README' file for
instructions specific to this package. Some packages provide this
`INSTALL' file but do not implement all of the features documented
'INSTALL' file but do not implement all of the features documented
below. The lack of an optional feature in a given package is not
necessarily a bug. More recommendations for GNU packages can be found
in *note Makefile Conventions: (standards)Makefile Conventions.
The `configure' shell script attempts to guess correct values for
The 'configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
those values to create a 'Makefile' in each directory of the package.
It may also create one or more '.h' files containing system-dependent
definitions. Finally, it creates a shell script 'config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
file 'config.log' containing compiler output (useful mainly for
debugging 'configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. Caching is
disabled by default to prevent problems with accidental use of stale
cache files.
It can also use an optional file (typically called 'config.cache' and
enabled with '--cache-file=config.cache' or simply '-C') that saves the
results of its tests to speed up reconfiguring. Caching is disabled by
default to prevent problems with accidental use of stale cache files.
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
to figure out how 'configure' could check whether to do them, and mail
diffs or instructions to the address given in the 'README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
some point 'config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You need `configure.ac' if
you want to change it or regenerate `configure' using a newer version
of `autoconf'.
The file 'configure.ac' (or 'configure.in') is used to create
'configure' by a program called 'autoconf'. You need 'configure.ac' if
you want to change it or regenerate 'configure' using a newer version of
'autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system.
1. 'cd' to the directory containing the package's source code and type
'./configure' to configure the package for your system.
Running `configure' might take a while. While running, it prints
Running 'configure' might take a while. While running, it prints
some messages telling which features it is checking for.
2. Type `make' to compile the package.
2. Type 'make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
3. Optionally, type 'make check' to run any self-tests that come with
the package, generally using the just-built uninstalled binaries.
4. Type `make install' to install the programs and any data files and
4. Type 'make install' to install the programs and any data files and
documentation. When installing into a prefix owned by root, it is
recommended that the package be configured and built as a regular
user, and only the `make install' phase executed with root
user, and only the 'make install' phase executed with root
privileges.
5. Optionally, type `make installcheck' to repeat any self-tests, but
5. Optionally, type 'make installcheck' to repeat any self-tests, but
this time using the binaries in their final installed location.
This target does not install anything. Running this target as a
regular user, particularly if the prior `make install' required
regular user, particularly if the prior 'make install' required
root privileges, verifies that the installation completed
correctly.
6. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
source code directory by typing 'make clean'. To also remove the
files that 'configure' created (so you can compile the package for
a different kind of computer), type 'make distclean'. There is
also a 'make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
7. Often, you can also type `make uninstall' to remove the installed
7. Often, you can also type 'make uninstall' to remove the installed
files again. In practice, not all packages have tested that
uninstallation works correctly, even though it is required by the
GNU Coding Standards.
8. Some packages, particularly those that use Automake, provide `make
8. Some packages, particularly those that use Automake, provide 'make
distcheck', which can by used by developers to test that all other
targets like `make install' and `make uninstall' work correctly.
targets like 'make install' and 'make uninstall' work correctly.
This target is generally not run by end users.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. Run `./configure --help'
the 'configure' script does not know about. Run './configure --help'
for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
You can give 'configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here is
an example:
./configure CC=c99 CFLAGS=-g LIBS=-lposix
@ -113,21 +112,21 @@ Compiling For Multiple Architectures
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you can use GNU `make'. `cd' to the
own directory. To do this, you can use GNU 'make'. 'cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'. This
is known as a "VPATH" build.
the 'configure' script. 'configure' automatically checks for the source
code in the directory that 'configure' is in and in '..'. This is known
as a "VPATH" build.
With a non-GNU `make', it is safer to compile the package for one
With a non-GNU 'make', it is safer to compile the package for one
architecture at a time in the source code directory. After you have
installed the package for one architecture, use `make distclean' before
installed the package for one architecture, use 'make distclean' before
reconfiguring for another architecture.
On MacOS X 10.5 and later systems, you can create libraries and
executables that work on multiple system types--known as "fat" or
"universal" binaries--by specifying multiple `-arch' options to the
compiler but only a single `-arch' option to the preprocessor. Like
"universal" binaries--by specifying multiple '-arch' options to the
compiler but only a single '-arch' option to the preprocessor. Like
this:
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
@ -136,100 +135,104 @@ this:
This is not guaranteed to produce working output in all cases, you
may have to build one architecture at a time and combine the results
using the `lipo' tool if you have problems.
using the 'lipo' tool if you have problems.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX', where PREFIX must be an
By default, 'make install' installs the package's commands under
'/usr/local/bin', include files under '/usr/local/include', etc. You
can specify an installation prefix other than '/usr/local' by giving
'configure' the option '--prefix=PREFIX', where PREFIX must be an
absolute file name.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
pass the option '--exec-prefix=PREFIX' to 'configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them. In general, the
default for these options is expressed in terms of `${prefix}', so that
specifying just `--prefix' will affect all of the other directory
options like '--bindir=DIR' to specify different values for particular
kinds of files. Run 'configure --help' for a list of the directories
you can set and what kinds of files go in them. In general, the default
for these options is expressed in terms of '${prefix}', so that
specifying just '--prefix' will affect all of the other directory
specifications that were not explicitly provided.
The most portable way to affect installation locations is to pass the
correct locations to `configure'; however, many packages provide one or
correct locations to 'configure'; however, many packages provide one or
both of the following shortcuts of passing variable assignments to the
`make install' command line to change installation locations without
'make install' command line to change installation locations without
having to reconfigure or recompile.
The first method involves providing an override variable for each
affected directory. For example, `make install
affected directory. For example, 'make install
prefix=/alternate/directory' will choose an alternate location for all
directory configuration variables that were expressed in terms of
`${prefix}'. Any directories that were specified during `configure',
but not in terms of `${prefix}', must each be overridden at install
time for the entire installation to be relocated. The approach of
makefile variable overrides for each directory variable is required by
the GNU Coding Standards, and ideally causes no recompilation.
However, some platforms have known limitations with the semantics of
shared libraries that end up requiring recompilation when using this
method, particularly noticeable in packages that use GNU Libtool.
'${prefix}'. Any directories that were specified during 'configure',
but not in terms of '${prefix}', must each be overridden at install time
for the entire installation to be relocated. The approach of makefile
variable overrides for each directory variable is required by the GNU
Coding Standards, and ideally causes no recompilation. However, some
platforms have known limitations with the semantics of shared libraries
that end up requiring recompilation when using this method, particularly
noticeable in packages that use GNU Libtool.
The second method involves providing the `DESTDIR' variable. For
example, `make install DESTDIR=/alternate/directory' will prepend
`/alternate/directory' before all installation names. The approach of
`DESTDIR' overrides is not required by the GNU Coding Standards, and
The second method involves providing the 'DESTDIR' variable. For
example, 'make install DESTDIR=/alternate/directory' will prepend
'/alternate/directory' before all installation names. The approach of
'DESTDIR' overrides is not required by the GNU Coding Standards, and
does not work on platforms that have drive letters. On the other hand,
it does better at avoiding recompilation issues, and works well even
when some directory options were not specified in terms of `${prefix}'
at `configure' time.
when some directory options were not specified in terms of '${prefix}'
at 'configure' time.
Optional Features
=================
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
with an extra prefix or suffix on their names by giving 'configure' the
option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'.
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
Some packages pay attention to '--enable-FEATURE' options to
'configure', where FEATURE indicates an optional part of the package.
They may also pay attention to '--with-PACKAGE' options, where PACKAGE
is something like 'gnu-as' or 'x' (for the X Window System). The
'README' should mention any '--enable-' and '--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
For packages that use the X Window System, 'configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
you can use the 'configure' options '--x-includes=DIR' and
'--x-libraries=DIR' to specify their locations.
Some packages offer the ability to configure how verbose the
execution of `make' will be. For these packages, running `./configure
execution of 'make' will be. For these packages, running './configure
--enable-silent-rules' sets the default to minimal output, which can be
overridden with `make V=1'; while running `./configure
overridden with 'make V=1'; while running './configure
--disable-silent-rules' sets the default to verbose, which can be
overridden with `make V=0'.
overridden with 'make V=0'.
Particular systems
==================
On HP-UX, the default C compiler is not ANSI C compatible. If GNU
CC is not installed, it is recommended to use the following options in
On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC
is not installed, it is recommended to use the following options in
order to use an ANSI C compiler:
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
HP-UX 'make' updates targets which have the same time stamps as their
prerequisites, which makes it generally unusable when shipped generated
files such as 'configure' are involved. Use GNU 'make' instead.
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
a workaround. If GNU CC is not installed, it is therefore recommended
to try
parse its '<wchar.h>' header file. The option '-nodtk' can be used as a
workaround. If GNU CC is not installed, it is therefore recommended to
try
./configure CC="cc"
@ -237,26 +240,26 @@ and if that doesn't work, try
./configure CC="cc -nodtk"
On Solaris, don't put `/usr/ucb' early in your `PATH'. This
On Solaris, don't put '/usr/ucb' early in your 'PATH'. This
directory contains several dysfunctional programs; working variants of
these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
in your `PATH', put it _after_ `/usr/bin'.
these programs are available in '/usr/bin'. So, if you need '/usr/ucb'
in your 'PATH', put it _after_ '/usr/bin'.
On Haiku, software installed for all users goes in `/boot/common',
not `/usr/local'. It is recommended to use the following options:
On Haiku, software installed for all users goes in '/boot/common',
not '/usr/local'. It is recommended to use the following options:
./configure --prefix=/boot/common
Specifying the System Type
==========================
There may be some features `configure' cannot figure out
There may be some features 'configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
_same_ architectures, 'configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
'--build=TYPE' option. TYPE can either be a short name for the system
type, such as 'sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
@ -265,101 +268,101 @@ where SYSTEM can have one of these forms:
OS
KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
See the file 'config.sub' for the possible values of each field. If
'config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
use the option '--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
eventually be run) with '--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
If you want to set default values for 'configure' scripts to share,
you can create a site shell script called 'config.site' that gives
default values for variables like 'CC', 'cache_file', and 'prefix'.
'configure' looks for 'PREFIX/share/config.site' if it exists, then
'PREFIX/etc/config.site' if it exists. Or, you can set the
'CONFIG_SITE' environment variable to the location of the site script.
A warning: not all 'configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
environment passed to 'configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
them in the 'configure' command line, using 'VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
causes the specified 'gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
an Autoconf bug. Until the bug is fixed you can use this workaround:
Unfortunately, this technique does not work for 'CONFIG_SHELL' due to an
Autoconf limitation. Until the limitation is lifted, you can use this
workaround:
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation
'configure' Invocation
======================
`configure' recognizes the following options to control how it
'configure' recognizes the following options to control how it
operates.
`--help'
`-h'
Print a summary of all of the options to `configure', and exit.
'--help'
'-h'
Print a summary of all of the options to 'configure', and exit.
`--help=short'
`--help=recursive'
'--help=short'
'--help=recursive'
Print a summary of the options unique to this package's
`configure', and exit. The `short' variant lists options used
only in the top level, while the `recursive' variant lists options
also present in any nested packages.
'configure', and exit. The 'short' variant lists options used only
in the top level, while the 'recursive' variant lists options also
present in any nested packages.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
'--version'
'-V'
Print the version of Autoconf used to generate the 'configure'
script, and exit.
`--cache-file=FILE'
'--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
traditionally 'config.cache'. FILE defaults to '/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
'--config-cache'
'-C'
Alias for '--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
'--quiet'
'--silent'
'-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
suppress all normal output, redirect it to '/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
'--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
'configure' can determine that directory automatically.
`--prefix=DIR'
Use DIR as the installation prefix. *note Installation Names::
for more details, including other options available for fine-tuning
the installation locations.
'--prefix=DIR'
Use DIR as the installation prefix. *note Installation Names:: for
more details, including other options available for fine-tuning the
installation locations.
`--no-create'
`-n'
'--no-create'
'-n'
Run the configure checks, but stop before creating any output
files.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.
'configure' also accepts some other, not widely useful, options. Run
'configure --help' for more details.

View File

@ -1,9 +1,8 @@
##
## SPDX-License-Identifier: 0BSD
## Author: Lasse Collin
##
## This file has been put into the public domain.
## You can do whatever you want with this file.
##
# Use -n to prevent gzip from adding a timestamp to the .gz headers.
GZIP_ENV = -9n
DIST_SUBDIRS = lib src po tests debug
SUBDIRS =
@ -14,14 +13,15 @@ endif
SUBDIRS += src po tests
if COND_DOC
dist_doc_DATA = \
AUTHORS \
COPYING \
COPYING.0BSD \
COPYING.GPLv2 \
NEWS \
README \
THANKS \
TODO \
doc/faq.txt \
doc/history.txt \
doc/xz-file-format.txt \
@ -29,26 +29,51 @@ dist_doc_DATA = \
examplesdir = $(docdir)/examples
dist_examples_DATA = \
doc/examples/xz_pipe_comp.c \
doc/examples/xz_pipe_decomp.c
doc/examples/00_README.txt \
doc/examples/01_compress_easy.c \
doc/examples/02_decompress.c \
doc/examples/03_compress_custom.c \
doc/examples/04_compress_easy_mt.c \
doc/examples/11_file_info.c \
doc/examples/Makefile
# Install the Doxygen generated documentation if they were built.
install-data-local:
if test -d "$(srcdir)/doc/api" ; then \
$(MKDIR_P) "$(DESTDIR)$(docdir)/api" && \
$(INSTALL_DATA) "$(srcdir)"/doc/api/* \
"$(DESTDIR)$(docdir)/api"; \
fi
# Remove the Doxygen generated documentation when uninstalling.
uninstall-local:
rm -rf "$(DESTDIR)$(docdir)/api"
endif
EXTRA_DIST = \
extra \
cmake \
dos \
doxygen \
extra \
po4a \
windows \
autogen.sh \
Doxyfile.in \
CMakeLists.txt \
COPYING.CC-BY-SA-4.0 \
COPYING.GPLv2 \
COPYING.GPLv3 \
COPYING.LGPLv2.1 \
INSTALL.generic \
PACKAGERS \
TODO \
autogen.sh \
build-aux/manconv.sh \
build-aux/version.sh
build-aux/version.sh \
doc/xz-logo.png \
po/xz.pot-header
ACLOCAL_AMFLAGS = -I m4
# List of man pages to conver to PDF and plain text in the dist-hook target.
# List of man pages to convert to PDF and plain text in the dist-hook target.
manfiles = \
src/xz/xz.1 \
src/xzdec/xzdec.1 \
@ -62,7 +87,8 @@ manfiles = \
# Convert the man pages to PDF and plain text (ASCII only) formats.
dist-hook:
if test -d "$(srcdir)/.git" && type git > /dev/null 2>&1; then \
( cd "$(srcdir)" && git log --date=iso --stat ) \
( cd "$(srcdir)" && git log --date=iso --stat \
b69da6d4bb6bb11fc0cf066920791990d2b22a06^..HEAD ) \
> "$(distdir)/ChangeLog"; \
fi
if type groff > /dev/null 2>&1 && type ps2pdf > /dev/null 2>&1; then \
@ -81,9 +107,19 @@ dist-hook:
> "$$dest/txt/$$BASE.txt"; \
done; \
fi
if test -d "$(srcdir)/doc/api" ; then \
$(MKDIR_P) "$(distdir)/doc/api" && \
$(INSTALL_DATA) "$(srcdir)"/doc/api/* \
"$(distdir)/doc/api"; \
fi
# This works with GNU tar and gives cleaner package than normal 'make dist'.
# This also ensures that the man page translations are up to date (dist-hook
# would be too late for that).
mydist:
sh "$(srcdir)/src/liblzma/validate_map.sh"
cd "$(srcdir)/po4a" && sh update-po
cd "$(srcdir)/doxygen" && sh update-doxygen
VERSION=$(VERSION); \
if test -d "$(srcdir)/.git" && type git > /dev/null 2>&1; then \
SNAPSHOT=`cd "$(srcdir)" && git describe --abbrev=4 | cut -b2-`; \

2102
NEWS

File diff suppressed because it is too large Load Diff

View File

@ -44,6 +44,8 @@ Information to packagers of XZ Utils
lzmadec binary for compatibility with LZMA Utils
liblzma liblzma.so.*
liblzma-devel liblzma.so, liblzma.a, API headers
liblzma-doc Doxygen-generated liblzma API docs (HTML),
example programs
2. Package description
@ -109,20 +111,28 @@ Information to packagers of XZ Utils
This package includes the API headers, static library, and
other development files related to liblzma.
liblzma-doc:
liblzma API documentation in HTML and example usage
This package includes the Doxygen-generated liblzma API
HTML docs and example programs showing how to use liblzma.
3. License
----------
If the package manager supports a license field, you probably should
put GPLv2+ there (GNU GPL v2 or later). The interesting parts of
XZ Utils are in the public domain, but some less important files
ending up into the binary package are under GPLv2+. So it is simplest
to just say GPLv2+ if you cannot specify "public domain and GPLv2+".
XZ Utils are under the BSD Zero Clause License (0BSD), but some less
important files ending up into the binary package are under GPLv2+.
So it is simplest to just say GPLv2+ if you cannot specify
"BSD0 and GPLv2+".
If you split XZ Utils into multiple packages as described earlier
in this file, liblzma and liblzma-dev packages will contain only
public domain code (from XZ Utils at least; compiler or linker may
add some third-party code, which may be copyrighted).
0BSD-licensed code from XZ Utils (compiler or linker may add some
third-party code which may have other licenses).
4. configure options
@ -138,6 +148,8 @@ Information to packagers of XZ Utils
--enable-checks
--enable-small (*)
--disable-threads (*)
--disable-microlzma (*)
--disable-lzip-decoder (*)
(*) These are OK when building xzdec and lzmadec as described
in INSTALL.
@ -158,12 +170,13 @@ Information to packagers of XZ Utils
can be replaced with a symlink if your distro ships with shared
copies of the common license texts.
liblzma API is currently only documented using Doxygen tags in the
API headers. It hasn't been tested much how good results Doxygen
is able to make from the tags (e.g. Doxyfile might need tweaking,
the tagging may need to be improved etc.), so it might be simpler
to just let people read docs directly from the .h files for now,
and also save quite a bit in package size at the same time.
The Doxygen-generated documentation (HTML) for the liblzma API
headers is included in the source release and will be installed by
"make install" to $docdir/api. All JavaScript is removed to
simplify license compliance and to reduce the install size. If the
liblzma API documentation is not desired, either run configure with
--disable-doc or remove the doc/api directory before running
"make install".
6. Extra files

170
README
View File

@ -5,11 +5,11 @@ XZ Utils
0. Overview
1. Documentation
1.1. Overall documentation
1.2. Documentation for command line tools
1.2. Documentation for command-line tools
1.3. Documentation for liblzma
2. Version numbering
3. Reporting bugs
4. Translating the xz tool
4. Translations
5. Other implementations of the .xz format
6. Contact information
@ -17,21 +17,21 @@ XZ Utils
0. Overview
-----------
XZ Utils provide a general-purpose data compression library and
command line tools. The native file format is the .xz format, but
XZ Utils provide a general-purpose data-compression library plus
command-line tools. The native file format is the .xz format, but
also the legacy .lzma format is supported. The .xz format supports
multiple compression algorithms, which are called "filters" in
multiple compression algorithms, which are called "filters" in the
context of XZ Utils. The primary filter is currently LZMA2. With
typical files, XZ Utils create about 30 % smaller files than gzip.
To ease adapting support for the .xz format into existing applications
and scripts, the API of liblzma is somewhat similar to the API of the
popular zlib library. For the same reason, the command line tool xz
has similar command line syntax than that of gzip.
popular zlib library. For the same reason, the command-line tool xz
has a command-line syntax similar to that of gzip.
When aiming for the highest compression ratio, LZMA2 encoder uses
When aiming for the highest compression ratio, the LZMA2 encoder uses
a lot of CPU time and may use, depending on the settings, even
hundreds of megabytes of RAM. However, in fast modes, LZMA2 encoder
hundreds of megabytes of RAM. However, in fast modes, the LZMA2 encoder
competes with bzip2 in compression speed, RAM usage, and compression
ratio.
@ -44,8 +44,8 @@ XZ Utils
since that needs to be done only once to benefit many people.
With some file types, combining (or "chaining") LZMA2 with an
additional filter can improve compression ratio. A filter chain may
contain up to four filters, although usually only one two is used.
additional filter can improve the compression ratio. A filter chain may
contain up to four filters, although usually only one or two are used.
For example, putting a BCJ (Branch/Call/Jump) filter before LZMA2
in the filter chain can improve compression ratio of executable files.
@ -55,9 +55,11 @@ XZ Utils
Similarly, it is possible that some day there is a filter that will
compress better than LZMA2.
XZ Utils doesn't support multithreaded compression or decompression
yet. It has been planned though and taken into account when designing
the .xz file format.
XZ Utils supports multithreaded compression. XZ Utils doesn't support
multithreaded decompression yet. It has been planned though and taken
into account when designing the .xz file format. In the future, files
that were created in threaded mode can be decompressed in threaded
mode too.
1. Documentation
@ -65,32 +67,35 @@ XZ Utils
1.1. Overall documentation
README This file
README This file
INSTALL.generic Generic install instructions for those not familiar
with packages using GNU Autotools
INSTALL Installation instructions specific to XZ Utils
PACKAGERS Information to packagers of XZ Utils
INSTALL.generic Generic install instructions for those not
familiar with packages using GNU Autotools
INSTALL Installation instructions specific to XZ Utils
PACKAGERS Information to packagers of XZ Utils
COPYING XZ Utils copyright and license information
COPYING.GPLv2 GNU General Public License version 2
COPYING.GPLv3 GNU General Public License version 3
COPYING.LGPLv2.1 GNU Lesser General Public License version 2.1
COPYING XZ Utils copyright and license information
COPYING.0BSD BSD Zero Clause License
COPYING.GPLv2 GNU General Public License version 2
COPYING.GPLv3 GNU General Public License version 3
COPYING.LGPLv2.1 GNU Lesser General Public License version 2.1
COPYING.CC-BY-SA-4.0 Creative Commons Attribution-ShareAlike 4.0
International Public License
AUTHORS The main authors of XZ Utils
THANKS Incomplete list of people who have helped making
this software
NEWS User-visible changes between XZ Utils releases
ChangeLog Detailed list of changes (commit log)
TODO Known bugs and some sort of to-do list
AUTHORS The main authors of XZ Utils
THANKS Incomplete list of people who have helped making
this software
NEWS User-visible changes between XZ Utils releases
ChangeLog Detailed list of changes (commit log)
TODO Known bugs and some sort of to-do list
Note that only some of the above files are included in binary
packages.
1.2. Documentation for command line tools
1.2. Documentation for command-line tools
The command line tools are documented as man pages. In source code
The command-line tools are documented as man pages. In source code
releases (and possibly also in some binary packages), the man pages
are also provided in plain text (ASCII only) and PDF formats in the
directory "doc/man" to make the man pages more accessible to those
@ -103,17 +108,16 @@ XZ Utils
and data type as Doxygen tags. These docs should be quite OK as
a quick reference.
I have planned to write a bunch of very well documented example
programs, which (due to comments) should work as a tutorial to
various features of liblzma. No such example programs have been
written yet.
There are a few example/tutorial programs that should help in
getting started with liblzma. In the source package the examples
are in "doc/examples" and in binary packages they may be under
"examples" in the same directory as this README.
For now, if you have never used liblzma, libbzip2, or zlib, I
recommend learning *basics* of zlib API. Once you know that, it
should be easier to learn liblzma.
Since the liblzma API has similarities to the zlib API, some people
may find it useful to read the zlib docs and tutorial too:
http://zlib.net/manual.html
http://zlib.net/zlib_how.html
https://zlib.net/manual.html
https://zlib.net/zlib_how.html
2. Version numbering
@ -124,23 +128,27 @@ XZ Utils
- X is the major version. When this is incremented, the library
API and ABI break.
- Y is the minor version. It is incremented when new features are
added without breaking existing API or ABI. Even Y indicates
stable release and odd Y indicates unstable (alpha or beta
version).
- Y is the minor version. It is incremented when new features
are added without breaking the existing API or ABI. An even Y
indicates a stable release and an odd Y indicates unstable
(alpha or beta version).
- Z is the revision. This has different meaning for stable and
- Z is the revision. This has a different meaning for stable and
unstable releases:
* Stable: Z is incremented when bugs get fixed without adding
any new features.
any new features. This is intended to be convenient for
downstream distributors that want bug fixes but don't want
any new features to minimize the risk of introducing new bugs.
* Unstable: Z is just a counter. API or ABI of features added
in earlier unstable releases having the same X.Y may break.
- S indicates stability of the release. It is missing from the
stable releases where Y is an even number. When Y is odd, S
stable releases, where Y is an even number. When Y is odd, S
is either "alpha" or "beta" to make it very clear that such
versions are not stable releases. The same X.Y.Z combination is
not used for more than one stability level i.e. after X.Y.Zalpha,
not used for more than one stability level, i.e. after X.Y.Zalpha,
the next version can be X.Y.(Z+1)beta but not X.Y.Zbeta.
@ -176,7 +184,7 @@ XZ Utils
Don't send core dump files or any executables. If you have a small
example file(s) (total size less than 256 KiB), please include
it/them as an attachment. If you have bigger test files, put them
online somewhere and include an URL to the file(s) in the bug report.
online somewhere and include a URL to the file(s) in the bug report.
Always include the exact version number of XZ Utils in the bug report.
If you are using a snapshot from the git repository, use "git describe"
@ -188,33 +196,33 @@ XZ Utils
system.
4. Translating the xz tool
--------------------------
4. Translations
---------------
The messages from the xz tool have been translated into a few
languages. Before starting to translate into a new language, ask
the author that someone else hasn't already started working on it.
The xz command line tool and all man pages can be translated.
The translations are handled via the Translation Project. If you
wish to help translating xz, please join the Translation Project:
Test your translation. Testing includes comparing the translated
output to the original English version by running the same commands
in both your target locale and with LC_ALL=C. Ask someone to
proof-read and test the translation.
https://translationproject.org/html/translators.html
Testing can be done e.g. by installing xz into a temporary directory:
Below are notes and testing instructions specific to xz
translations.
Testing can be done by installing xz into a temporary directory:
./configure --disable-shared --prefix=/tmp/xz-test
# <Edit the .po file in the po directory.>
make -C po update-po
make install
bash debug/translations.bash | less
bash debug/translations.bash | less -S # For --list outputs
bash debug/translation.bash | less
bash debug/translation.bash | less -S # For --list outputs
Repeat the above as needed (no need to re-run configure though).
Note especially the following:
- The output of --help and --long-help must look nice on
a 80-column terminal. It's OK to add extra lines if needed.
an 80-column terminal. It's OK to add extra lines if needed.
- In contrast, don't add extra lines to error messages and such.
They are often preceded with e.g. a filename on the same line,
@ -253,14 +261,11 @@ XZ Utils
at the beginning and end of the strings.
- Read the TRANSLATORS comments that have been extracted from the
source code and included in xz.pot. If they suggest testing the
translation with some type of command, do it. If testing needs
input files, use e.g. tests/files/good-*.xz.
- When updating the translation, read the fuzzy (modified) strings
carefully, and don't mark them as updated before you actually
have updated them. Reading through the unchanged messages can be
good too; sometimes you may find a better wording for them.
source code and included in xz.pot. Some comments suggest
testing with a specific command which needs an .xz file. You
may use e.g. any tests/files/good-*.xz. However, these test
commands are included in translations.bash output, so reading
translations.bash output carefully can be enough.
- If you find language problems in the original English strings,
feel free to suggest improvements. Ask if something is unclear.
@ -270,9 +275,7 @@ XZ Utils
make a direct word-by-word translation from English especially if
the result doesn't sound good in your language.
In short, take your time and pay attention to the details. Making
a good translation is not a quick and trivial thing to do. The
translated xz should look as polished as the English version.
Thanks for your help!
5. Other implementations of the .xz format
@ -281,24 +284,27 @@ XZ Utils
7-Zip and the p7zip port of 7-Zip support the .xz format starting
from the version 9.00alpha.
http://7-zip.org/
http://p7zip.sourceforge.net/
https://7-zip.org/
https://p7zip.sourceforge.net/
XZ Embedded is a limited implementation written for use in the Linux
kernel, but it is also suitable for other embedded use.
http://tukaani.org/xz/embedded.html
https://xz.tukaani.org/xz-embedded/
XZ for Java is a complete implementation written in pure Java.
https://xz.tukaani.org/xz-for-java/
6. Contact information
----------------------
If you have questions, bug reports, patches etc. related to XZ Utils,
contact Lasse Collin <lasse.collin@tukaani.org> (in Finnish or English).
I'm sometimes slow at replying. If you haven't got a reply within two
weeks, assume that your email has got lost and resend it or use IRC.
the project maintainers Lasse Collin and Jia Tan can be reached via
<xz@tukaani.org>.
You can find me also from #tukaani on Freenode; my nick is Larhzu.
The channel tends to be pretty quiet, so just ask your question and
someone may wake up.
You might find Lasse also from #tukaani on Libera Chat (IRC).
The nick is Larhzu. The channel tends to be pretty quiet,
so just ask your question and someone might wake up.

110
THANKS
View File

@ -5,66 +5,174 @@ Thanks
Some people have helped more, some less, but nevertheless everyone's help
has been important. :-) In alphabetical order:
- Mark Adler
- Kian-Meng Ang
- H. Peter Anvin
- Jeff Bastian
- Nelson H. F. Beebe
- Karl Beldan
- Karl Berry
- Anders F. Björklund
- Emmanuel Blot
- Melanie Blower
- Alexander Bluhm
- Martin Blumenstingl
- Ben Boeckel
- Jakub Bogusz
- Adam Borowski
- Maarten Bosmans
- Lukas Braune
- Benjamin Buch
- Trent W. Buck
- Kevin R. Bulgrien
- James Buren
- David Burklund
- Frank Busse
- Daniel Mealha Cabrita
- Milo Casagrande
- Marek Černocký
- Tomer Chachamu
- Vitaly Chikunov
- Antoine Cœur
- Gabi Davar
- İhsan Doğan
- Chris Donawa
- Andrew Dudman
- Markus Duft
- İsmail Dönmez
- Paul Eggert
- Robert Elz
- Gilles Espinasse
- Denis Excoffier
- Vincent Fazio
- Michael Felt
- Michael Fox
- Mike Frysinger
- Daniel Richard G.
- Tomasz Gajc
- Bjarni Ingi Gislason
- John Paul Adrian Glaubitz
- Bill Glessner
- Matthew Good
- Michał Górny
- Jason Gorski
- Juan Manuel Guerrero
- Gabriela Gutierrez
- Diederik de Haas
- Joachim Henke
- Christian Hesse
- Vincenzo Innocente
- Peter Ivanov
- Nicholas Jackson
- Sam James
- Hajin Jang
- Hans Jansen
- Jouk Jansen
- Jun I Jin
- Kiyoshi Kanazawa
- Joona Kannisto
- Per Øyvind Karlsen
- Iouri Kharon
- Thomas Klausner
- Richard Koch
- Anton Kochkov
- Ville Koskinen
- Sergey Kosukhin
- Marcin Kowalczyk
- Jan Kratochvil
- Christian Kujau
- Stephan Kulow
- Ilya Kurdyukov
- Peter Lawler
- James M Leddy
- Kelvin Lee
- Vincent Lefevre
- Hin-Tak Leung
- Andraž 'ruskie' Levstik
- Cary Lewis
- Wim Lewis
- Xin Li
- Eric Lindblad
- Lorenzo De Liso
- H.J. Lu
- Bela Lubkin
- Chenxi Mao
- Gregory Margo
- Julien Marrec
- Ed Maste
- Martin Matuška
- Ivan A. Melnikov
- Jim Meyering
- Arkadiusz Miskiewicz
- Nathan Moinvaziri
- Étienne Mollier
- Conley Moorhous
- Rafał Mużyło
- Adrien Nader
- Evan Nemerson
- Hongbo Ni
- Jonathan Nieder
- Andre Noll
- Peter O'Gorman
- Dimitri Papadopoulos Orfanos
- Daniel Packard
- Filip Palian
- Peter Pallinger
- Rui Paulo
- Igor Pavlov
- Diego Elio Pettenò
- Elbert Pol
- Mikko Pouru
- Rich Prohaska
- Trần Ngọc Quân
- Pavel Raiskup
- Ole André Vadla Ravnås
- Eric S. Raymond
- Robert Readman
- Bernhard Reutner-Fischer
- Markus Rickert
- Cristian Rodríguez
- Christian von Roques
- Boud Roukema
- Torsten Rupp
- Stephen Sachs
- Jukka Salmi
- Agostino Sarubbo
- Alexandre Sauvé
- Benno Schulenberg
- Andreas Schwab
- Bhargava Shastry
- Dan Shechter
- Stuart Shelton
- Sebastian Andrzej Siewior
- Ville Skyttä
- Brad Smith
- Bruce Stark
- Pippijn van Steenhoven
- Martin Storsjö
- Jonathan Stott
- Dan Stromberg
- Jia Tan
- Vincent Torri
- Alexey Tourbin
- Paul Townsend
- Mohammed Adnène Trojette
- Alexey Tourbin
- Taiki Tsunekawa
- Maksym Vatsyk
- Loganaden Velvindron
- Patrick J. Volkerding
- Martin Väth
- Adam Walling
- Jeffrey Walton
- Christian Weisgerber
- Dan Weiss
- Bert Wesarg
- Fredrik Wikstrom
- Jim Wilcoxson
- Ralf Wildenhues
- Charles Wilson
- Lars Wirzenius
- Pilorz Wojciech
- Chien Wong
- Ryan Young
- Andreas Zieringer

66
TODO
View File

@ -12,10 +12,6 @@ Known bugs
it would be possible by switching from BT2/BT3/BT4 match finder to
HC3/HC4.
The code to detect number of CPU cores doesn't count hyperthreading
as multiple cores. In context of xz, it probably should.
Hyperthreading is good at least with p7zip.
XZ Utils compress some files significantly worse than LZMA Utils.
This is due to faster compression presets used by XZ Utils, and
can often be worked around by using "xz --extreme". With some files
@ -28,20 +24,36 @@ Known bugs
tuklib_exit() doesn't block signals => EINTR is possible.
SIGTSTP is not handled. If xz is stopped, the estimated remaining
time and calculated (de)compression speed won't make sense in the
progress indicator (xz --verbose).
If liblzma has created threads and fork() gets called, liblzma
code will break in the child process unless it calls exec() and
doesn't touch liblzma.
Missing features
----------------
Add support for storing metadata in .xz files. A preliminary
idea is to create a new Stream type for metadata. When both
metadata and data are wanted in the same .xz file, two or more
Streams would be concatenated.
The state stored in lzma_stream should be cloneable, which would
be mostly useful when using a preset dictionary in LZMA2, but
it may have other uses too. Compare to deflateCopy() in zlib.
Support LZMA_FINISH in raw decoder to indicate end of LZMA1 and
other streams that don't have an end of payload marker.
Adjust dictionary size when the input file size is known.
Maybe do this only if an option is given.
xz doesn't support copying extended attributes, access control
lists etc. from source to target file.
Multithreaded compression
Multithreaded decompression
Multithreaded compression:
- Reduce memory usage of the current method.
- Implement threaded match finders.
- Implement pigz-style threading in LZMA2.
Buffer-to-buffer coding could use less RAM (especially when
decompressing LZMA1 or LZMA2).
@ -50,18 +62,44 @@ Missing features
It will be a separate library that supports uncompressed, .gz,
.bz2, .lzma, and .xz files.
Support changing lzma_options_lzma.mode with lzma_filters_update().
Support LZMA_FULL_FLUSH for lzma_stream_decoder() to stop at
Block and Stream boundaries.
lzma_strerror() to convert lzma_ret to human readable form?
This is tricky, because the same error codes are used with
slightly different meanings, and this cannot be fixed anymore.
Make it possible to adjust LZMA2 options in the middle of a Block
so that the encoding speed vs. compression ratio can be optimized
when the compressed data is streamed over network.
Improved BCJ filters. The current filters are small but they aren't
so great when compressing binary packages that contain various file
types. Specifically, they make things worse if there are static
libraries or Linux kernel modules. The filtering could also be
more effective (without getting overly complex), for example,
streamable variant BCJ2 from 7-Zip could be implemented.
Filter that autodetects specific data types in the input stream
and applies appropriate filters for the corrects parts of the input.
Perhaps combine this with the BCJ filter improvement point above.
Long-range LZ77 method as a separate filter or as a new LZMA2
match finder.
Documentation
-------------
Some tutorial is needed for liblzma. I have planned to write some
extremely well commented example programs, which would work as
a tutorial. I suppose the Doxygen tags are quite OK as a quick
reference once one is familiar with the liblzma API.
More tutorial programs are needed for liblzma.
Document the LZMA1 and LZMA2 algorithms.
Miscellaneous
------------
Try to get the media type for .xz registered at IANA.

View File

@ -1,22 +1,54 @@
#!/bin/sh
# SPDX-License-Identifier: 0BSD
###############################################################################
#
# Author: Lasse Collin
#
# This file has been put into the public domain.
# You can do whatever you want with this file.
#
###############################################################################
# The result of using "autoreconf -fi" should be identical to using this
# script. I'm leaving this script here just in case someone finds it useful.
set -e -x
# The following six lines are almost identical to "autoreconf -fi" but faster.
${AUTOPOINT:-autopoint} -f
${LIBTOOLIZE:-libtoolize} -c -f || glibtoolize -c -f
${ACLOCAL:-aclocal} -I m4
${AUTOCONF:-autoconf}
${AUTOHEADER:-autoheader}
${AUTOMAKE:-automake} -acf --foreign
# Generate the translated man pages and the doxygen documentation if the
# "po4a" and "doxygen" tools are available.
# This is *NOT* done by "autoreconf -fi" or when "make" is run.
# Pass --no-po4a or --no-doxygen to this script to skip these steps.
# It can be useful when you know that po4a or doxygen aren't available and
# don't want autogen.sh to exit with non-zero exit status.
generate_po4a="y"
generate_doxygen="y"
for arg in "$@"
do
case $arg in
"--no-po4a")
generate_po4a="n"
;;
"--no-doxygen")
generate_doxygen="n"
;;
esac
done
if test "$generate_po4a" != "n"; then
cd po4a
sh update-po
cd ..
fi
if test "$generate_doxygen" != "n"; then
cd doxygen
sh update-doxygen
cd ..
fi
exit 0

287
build-aux/ci_build.sh Executable file
View File

@ -0,0 +1,287 @@
#!/bin/bash
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# Script meant to be used for Continuous Integration automation for POSIX
# systems. On GitHub, this is used by Ubuntu and MacOS builds.
#
#############################################################################
#
# Author: Jia Tan
#
#############################################################################
set -e
USAGE="Usage: $0
-a [autogen flags]
-b [autotools|cmake]
-c [crc32|crc64|sha256]
-d [encoders|decoders|bcj|delta|threads|shared|nls|small|ifunc|clmul|sandbox]
-f [CFLAGS]
-l [destdir]
-m [compiler]
-n [ARTIFACTS_DIR_NAME]
-p [all|build|test]
-s [srcdir]"
# Absolute path of script directory
ABS_DIR=$(cd -- "$(dirname -- "$0")" && pwd)
# Default CLI option values
AUTOGEN_FLAGS=""
BUILD_SYSTEM="autotools"
CHECK_TYPE="crc32,crc64,sha256"
BCJ="y"
DELTA="y"
ENCODERS="y"
DECODERS="y"
THREADS="y"
SHARED="y"
NATIVE_LANG_SUPPORT="y"
SMALL="n"
IFUNC="y"
CLMUL="y"
SANDBOX="y"
SRC_DIR="$ABS_DIR/../"
DEST_DIR="$SRC_DIR/../xz_build"
PHASE="all"
ARTIFACTS_DIR_NAME="output"
###################
# Parse arguments #
###################
while getopts a:b:c:d:l:m:n:s:p:f:h opt; do
# b option can have either value "autotools" OR "cmake"
case ${opt} in
h)
echo "$USAGE"
exit 0
;;
a)
AUTOGEN_FLAGS="$OPTARG"
;;
b)
case "$OPTARG" in
autotools) ;;
cmake) ;;
*) echo "Invalid build system: $OPTARG"; exit 1;;
esac
BUILD_SYSTEM="$OPTARG"
;;
c) CHECK_TYPE="$OPTARG"
;;
# d options can be a comma separated list of things to disable at
# configure time
d)
for disable_arg in $(echo "$OPTARG" | sed "s/,/ /g"); do
case "$disable_arg" in
encoders) ENCODERS="n" ;;
decoders) DECODERS="n" ;;
bcj) BCJ="n" ;;
delta) DELTA="n" ;;
threads) THREADS="n" ;;
shared) SHARED="n";;
nls) NATIVE_LANG_SUPPORT="n";;
small) SMALL="y";;
ifunc) IFUNC="n";;
clmul) CLMUL="n";;
sandbox) SANDBOX="n";;
*) echo "Invalid disable value: $disable_arg"; exit 1 ;;
esac
done
;;
l) DEST_DIR="$OPTARG"
;;
m)
CC="$OPTARG"
export CC
;;
n) ARTIFACTS_DIR_NAME="$OPTARG"
;;
s) SRC_DIR="$OPTARG"
;;
p) PHASE="$OPTARG"
;;
f)
CFLAGS="$OPTARG"
export CFLAGS
;;
esac
done
####################
# Helper Functions #
####################
# These two functions essentially implement the ternary "?" operator.
add_extra_option() {
# First argument is option value ("y" or "n")
# Second argument is option to set if "y"
# Third argument is option to set if "n"
if [ "$1" = "y" ]
then
EXTRA_OPTIONS="$EXTRA_OPTIONS $2"
else
EXTRA_OPTIONS="$EXTRA_OPTIONS $3"
fi
}
add_to_filter_list() {
# First argument is option value ("y" or "n")
# Second argument is option to set if "y"
if [ "$1" = "y" ]
then
FILTER_LIST="$FILTER_LIST$2"
fi
}
###############
# Build Phase #
###############
if [ "$PHASE" = "all" ] || [ "$PHASE" = "build" ]
then
# Checksum options should be specified differently based on the
# build system. It must be calculated here since we won't know
# the build system used until all args have been parsed.
# Autotools - comma separated
# CMake - semi-colon separated
if [ "$BUILD_SYSTEM" = "autotools" ]
then
SEP=","
else
SEP=";"
fi
CHECK_TYPE_TEMP=""
for crc in $(echo "$CHECK_TYPE" | sed "s/,/ /g"); do
case "$crc" in
# Remove "crc32" from cmake build, if specified.
crc32)
if [ "$BUILD_SYSTEM" = "cmake" ]
then
continue
fi
;;
crc64) ;;
sha256) ;;
*) echo "Invalid check type: $crc"; exit 1 ;;
esac
CHECK_TYPE_TEMP="$CHECK_TYPE_TEMP$SEP$crc"
done
# Remove the first character from $CHECK_TYPE_TEMP since it will
# always be the delimiter.
CHECK_TYPE="${CHECK_TYPE_TEMP:1}"
FILTER_LIST="lzma1$SEP"lzma2
# Build based on arguments
mkdir -p "$DEST_DIR"
# Generate configure option values
EXTRA_OPTIONS=""
case $BUILD_SYSTEM in
autotools)
cd "$SRC_DIR"
# Run autogen.sh script if not already run
if [ ! -f configure ]
then
./autogen.sh "$AUTOGEN_FLAGS"
fi
cd "$DEST_DIR"
add_to_filter_list "$BCJ" ",x86,powerpc,ia64,arm,armthumb,arm64,sparc,riscv"
add_to_filter_list "$DELTA" ",delta"
add_extra_option "$ENCODERS" "--enable-encoders=$FILTER_LIST" "--disable-encoders"
add_extra_option "$DECODERS" "--enable-decoders=$FILTER_LIST" "--disable-decoders"
add_extra_option "$THREADS" "" "--disable-threads"
add_extra_option "$SHARED" "" "--disable-shared"
add_extra_option "$NATIVE_LANG_SUPPORT" "" "--disable-nls"
add_extra_option "$SMALL" "--enable-small" ""
add_extra_option "$IFUNC" "" "--disable-ifunc"
add_extra_option "$CLMUL" "" "--disable-clmul-crc"
add_extra_option "$SANDBOX" "" "--enable-sandbox=no"
# Run configure script
"$SRC_DIR"/configure --enable-werror --enable-checks="$CHECK_TYPE" $EXTRA_OPTIONS --config-cache
# Build the project
make
;;
cmake)
cd "$DEST_DIR"
add_to_filter_list "$BCJ" ";x86;powerpc;ia64;arm;armthumb;arm64;sparc;riscv"
add_to_filter_list "$DELTA" ";delta"
add_extra_option "$THREADS" "-DENABLE_THREADS=ON" "-DENABLE_THREADS=OFF"
# Disable MicroLZMA if encoders are not configured.
add_extra_option "$ENCODERS" "-DENCODERS=$FILTER_LIST" "-DENCODERS= -DMICROLZMA_ENCODER=OFF"
# Disable MicroLZMA and lzip decoders if decoders are not configured.
add_extra_option "$DECODERS" "-DDECODERS=$FILTER_LIST" "-DDECODERS= -DMICROLZMA_DECODER=OFF -DLZIP_DECODER=OFF"
# CMake disables the shared library by default.
add_extra_option "$SHARED" "-DBUILD_SHARED_LIBS=ON" ""
add_extra_option "$SMALL" "-DHAVE_SMALL=ON" ""
if test -n "$CC" ; then
EXTRA_OPTIONS="$EXTRA_OPTIONS -DCMAKE_C_COMPILER=$CC"
fi
# Remove old cache file to clear previous settings.
rm -f "CMakeCache.txt"
cmake "$SRC_DIR/CMakeLists.txt" -B "$DEST_DIR" $EXTRA_OPTIONS -DADDITIONAL_CHECK_TYPES="$CHECK_TYPE" -G "Unix Makefiles"
cmake --build "$DEST_DIR"
;;
esac
fi
##############
# Test Phase #
##############
if [ "$PHASE" = "all" ] || [ "$PHASE" = "test" ]
then
case $BUILD_SYSTEM in
autotools)
cd "$DEST_DIR"
# If the tests fail, copy the test logs into the artifacts folder
if make check
then
:
else
mkdir -p "$SRC_DIR/build-aux/artifacts/$ARTIFACTS_DIR_NAME"
cp ./tests/*.log "$SRC_DIR/build-aux/artifacts/$ARTIFACTS_DIR_NAME"
exit 1
fi
;;
cmake)
cd "$DEST_DIR"
if make test
then
:
else
mkdir -p "$SRC_DIR/build-aux/artifacts/$ARTIFACTS_DIR_NAME"
cp ./Testing/Temporary/*.log "$SRC_DIR/build-aux/artifacts/$ARTIFACTS_DIR_NAME"
exit 1
fi
;;
esac
fi

View File

@ -1,5 +1,6 @@
#!/bin/sh
#
# SPDX-License-Identifier: 0BSD
###############################################################################
#
# Wrapper for GNU groff to convert man pages to a few formats
@ -17,9 +18,6 @@
#
# Author: Lasse Collin
#
# This file has been put into the public domain.
# You can do whatever you want with this file.
#
###############################################################################
FORMAT=$1
@ -38,10 +36,10 @@ s/^\\.PD\$/.PD $PD/"
case $FORMAT in
ascii)
groff -t -mandoc -Tascii | col -bx
groff -t -mandoc -Tascii -P-c | col -bx
;;
utf8)
groff -t -mandoc -Tutf8 | col -bx
groff -t -mandoc -Tutf8 -P-c | col -bx
;;
ps)
sed "$SED_PD" | groff -dpaper=$PAPER -t -mandoc \

View File

@ -1,5 +1,6 @@
#!/bin/sh
#
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# Get the version string from version.h and print it out without
@ -9,9 +10,6 @@
#
# Author: Lasse Collin
#
# This file has been put into the public domain.
# You can do whatever you want with this file.
#
#############################################################################
sed -n 's/LZMA_VERSION_STABILITY_ALPHA/alpha/
@ -21,4 +19,4 @@ sed -n 's/LZMA_VERSION_STABILITY_ALPHA/alpha/
src/liblzma/api/lzma/version.h \
| tr '\n' '|' \
| sed 's/|/./; s/|/./; s/|//g' \
| tr -d '\n'
| tr -d '\r\n'

View File

@ -0,0 +1,25 @@
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# remove-ordinals.cmake
#
# Removes the ordinal numbers from a DEF file that has been created by
# GNU ld or LLVM lld option --output-def (when creating a Windows DLL).
# This should be equivalent: sed 's/ \+@ *[0-9]\+//'
#
# Usage:
#
# cmake -DINPUT_FILE=infile.def.in \
# -DOUTPUT_FILE=outfile.def \
# -P remove-ordinals.cmake
#
#############################################################################
#
# Author: Lasse Collin
#
#############################################################################
file(READ "${INPUT_FILE}" STR)
string(REGEX REPLACE " +@ *[0-9]+" "" STR "${STR}")
file(WRITE "${OUTPUT_FILE}" "${STR}")

50
cmake/tuklib_common.cmake Normal file
View File

@ -0,0 +1,50 @@
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# tuklib_common.cmake - common functions and macros for tuklib_*.cmake files
#
# Author: Lasse Collin
#
#############################################################################
function(tuklib_add_definitions TARGET_OR_ALL DEFINITIONS)
# DEFINITIONS may be an empty string/list but it's fine here. There is
# no need to quote ${DEFINITIONS} as empty arguments are fine here.
if(TARGET_OR_ALL STREQUAL "ALL")
add_compile_definitions(${DEFINITIONS})
else()
target_compile_definitions("${TARGET_OR_ALL}" PRIVATE ${DEFINITIONS})
endif()
endfunction()
function(tuklib_add_definition_if TARGET_OR_ALL VAR)
if(${VAR})
tuklib_add_definitions("${TARGET_OR_ALL}" "${VAR}")
endif()
endfunction()
# This is an over-simplified version of AC_USE_SYSTEM_EXTENSIONS in Autoconf
# or gl_USE_SYSTEM_EXTENSIONS in gnulib.
macro(tuklib_use_system_extensions TARGET_OR_ALL)
if(NOT WIN32)
# FIXME? The Solaris-specific __EXTENSIONS__ should be conditional
# even on Solaris. See gnulib: git log m4/extensions.m4.
# FIXME? gnulib and autoconf.git has lots of new stuff.
tuklib_add_definitions("${TARGET_OR_ALL}"
_GNU_SOURCE
__EXTENSIONS__
_POSIX_PTHREAD_SEMANTICS
_TANDEM_SOURCE
_ALL_SOURCE
)
list(APPEND CMAKE_REQUIRED_DEFINITIONS
-D_GNU_SOURCE
-D__EXTENSIONS__
-D_POSIX_PTHREAD_SEMANTICS
-D_TANDEM_SOURCE
-D_ALL_SOURCE
)
endif()
endmacro()

181
cmake/tuklib_cpucores.cmake Normal file
View File

@ -0,0 +1,181 @@
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# tuklib_cpucores.cmake - see tuklib_cpucores.m4 for description and comments
#
# Author: Lasse Collin
#
#############################################################################
include("${CMAKE_CURRENT_LIST_DIR}/tuklib_common.cmake")
include(CheckCSourceCompiles)
include(CheckIncludeFile)
function(tuklib_cpucores_internal_check)
if(WIN32 OR CYGWIN)
# Nothing to do, the tuklib_cpucores.c handles it.
set(TUKLIB_CPUCORES_DEFINITIONS "" CACHE INTERNAL "")
return()
endif()
# glibc-based systems (GNU/Linux and GNU/kFreeBSD) have
# sched_getaffinity(). The CPU_COUNT() macro was added in glibc 2.9.
# glibc 2.9 is old enough that if someone uses the code on older glibc,
# the fallback to sysconf() should be good enough.
#
# NOTE: This required that _GNU_SOURCE is defined. We assume that whatever
# feature test macros the caller wants to use are already set in
# CMAKE_REQUIRED_DEFINES and in the target defines.
check_c_source_compiles("
#include <sched.h>
int main(void)
{
cpu_set_t cpu_mask;
sched_getaffinity(0, sizeof(cpu_mask), &cpu_mask);
return CPU_COUNT(&cpu_mask);
}
"
TUKLIB_CPUCORES_SCHED_GETAFFINITY)
if(TUKLIB_CPUCORES_SCHED_GETAFFINITY)
set(TUKLIB_CPUCORES_DEFINITIONS
"TUKLIB_CPUCORES_SCHED_GETAFFINITY"
CACHE INTERNAL "")
return()
endif()
# FreeBSD has both cpuset and sysctl. Look for cpuset first because
# it's a better approach.
#
# This test would match on GNU/kFreeBSD too but it would require
# -lfreebsd-glue when linking and thus in the current form this would
# fail on GNU/kFreeBSD. The above test for sched_getaffinity() matches
# on GNU/kFreeBSD so the test below should never run on that OS.
check_c_source_compiles("
#include <sys/param.h>
#include <sys/cpuset.h>
int main(void)
{
cpuset_t set;
cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1,
sizeof(set), &set);
return 0;
}
"
TUKLIB_CPUCORES_CPUSET)
if(TUKLIB_CPUCORES_CPUSET)
set(TUKLIB_CPUCORES_DEFINITIONS "HAVE_PARAM_H;TUKLIB_CPUCORES_CPUSET"
CACHE INTERNAL "")
return()
endif()
# On OS/2, both sysconf() and sysctl() pass the tests in this file,
# but only sysctl() works. On QNX it's the opposite: only sysconf() works
# (although it assumes that _POSIX_SOURCE, _XOPEN_SOURCE, and
# _POSIX_C_SOURCE are undefined or alternatively _QNX_SOURCE is defined).
#
# We test sysctl() first and intentionally break the sysctl() test on QNX
# so that sysctl() is never used on QNX.
check_include_file(sys/param.h HAVE_SYS_PARAM_H)
if(HAVE_SYS_PARAM_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_PARAM_H)
endif()
check_c_source_compiles("
#ifdef __QNX__
compile error
#endif
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
#include <sys/sysctl.h>
int main(void)
{
#ifdef HW_NCPUONLINE
/* This is preferred on OpenBSD, see tuklib_cpucores.c. */
int name[2] = { CTL_HW, HW_NCPUONLINE };
#else
int name[2] = { CTL_HW, HW_NCPU };
#endif
int cpus;
size_t cpus_size = sizeof(cpus);
sysctl(name, 2, &cpus, &cpus_size, NULL, 0);
return 0;
}
"
TUKLIB_CPUCORES_SYSCTL)
if(TUKLIB_CPUCORES_SYSCTL)
if(HAVE_SYS_PARAM_H)
set(TUKLIB_CPUCORES_DEFINITIONS
"HAVE_PARAM_H;TUKLIB_CPUCORES_SYSCTL"
CACHE INTERNAL "")
else()
set(TUKLIB_CPUCORES_DEFINITIONS
"TUKLIB_CPUCORES_SYSCTL"
CACHE INTERNAL "")
endif()
return()
endif()
# Many platforms support sysconf().
check_c_source_compiles("
#include <unistd.h>
int main(void)
{
long i;
#ifdef _SC_NPROCESSORS_ONLN
/* Many systems using sysconf() */
i = sysconf(_SC_NPROCESSORS_ONLN);
#else
/* IRIX */
i = sysconf(_SC_NPROC_ONLN);
#endif
return 0;
}
"
TUKLIB_CPUCORES_SYSCONF)
if(TUKLIB_CPUCORES_SYSCONF)
set(TUKLIB_CPUCORES_DEFINITIONS "TUKLIB_CPUCORES_SYSCONF"
CACHE INTERNAL "")
return()
endif()
# HP-UX
check_c_source_compiles("
#include <sys/param.h>
#include <sys/pstat.h>
int main(void)
{
struct pst_dynamic pst;
pstat_getdynamic(&pst, sizeof(pst), 1, 0);
(void)pst.psd_proc_cnt;
return 0;
}
"
TUKLIB_CPUCORES_PSTAT_GETDYNAMIC)
if(TUKLIB_CPUCORES_PSTAT_GETDYNAMIC)
set(TUKLIB_CPUCORES_DEFINITIONS "TUKLIB_CPUCORES_PSTAT_GETDYNAMIC"
CACHE INTERNAL "")
return()
endif()
endfunction()
function(tuklib_cpucores TARGET_OR_ALL)
if(NOT DEFINED TUKLIB_CPUCORES_FOUND)
message(STATUS
"Checking how to detect the number of available CPU cores")
tuklib_cpucores_internal_check()
if(DEFINED TUKLIB_CPUCORES_DEFINITIONS)
set(TUKLIB_CPUCORES_FOUND 1 CACHE INTERNAL "")
else()
set(TUKLIB_CPUCORES_FOUND 0 CACHE INTERNAL "")
message(WARNING
"No method to detect the number of CPU cores was found")
endif()
endif()
if(TUKLIB_CPUCORES_FOUND)
tuklib_add_definitions("${TARGET_OR_ALL}"
"${TUKLIB_CPUCORES_DEFINITIONS}")
endif()
endfunction()

141
cmake/tuklib_integer.cmake Normal file
View File

@ -0,0 +1,141 @@
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# tuklib_integer.cmake - see tuklib_integer.m4 for description and comments
#
# Author: Lasse Collin
#
#############################################################################
include("${CMAKE_CURRENT_LIST_DIR}/tuklib_common.cmake")
include(TestBigEndian)
include(CheckCSourceCompiles)
include(CheckIncludeFile)
include(CheckSymbolExists)
function(tuklib_integer TARGET_OR_ALL)
# Check for endianness. Unlike the Autoconf's AC_C_BIGENDIAN, this doesn't
# support Apple universal binaries. The CMake module will leave the
# variable unset so we can catch that situation here instead of continuing
# as if we were little endian.
test_big_endian(WORDS_BIGENDIAN)
if(NOT DEFINED WORDS_BIGENDIAN)
message(FATAL_ERROR "Cannot determine endianness")
endif()
tuklib_add_definition_if("${TARGET_OR_ALL}" WORDS_BIGENDIAN)
# Look for a byteswapping method.
check_c_source_compiles("
int main(void)
{
__builtin_bswap16(1);
__builtin_bswap32(1);
__builtin_bswap64(1);
return 0;
}
"
HAVE___BUILTIN_BSWAPXX)
if(HAVE___BUILTIN_BSWAPXX)
tuklib_add_definitions("${TARGET_OR_ALL}" HAVE___BUILTIN_BSWAPXX)
else()
check_include_file(byteswap.h HAVE_BYTESWAP_H)
if(HAVE_BYTESWAP_H)
tuklib_add_definitions("${TARGET_OR_ALL}" HAVE_BYTESWAP_H)
check_symbol_exists(bswap_16 byteswap.h HAVE_BSWAP_16)
tuklib_add_definition_if("${TARGET_OR_ALL}" HAVE_BSWAP_16)
check_symbol_exists(bswap_32 byteswap.h HAVE_BSWAP_32)
tuklib_add_definition_if("${TARGET_OR_ALL}" HAVE_BSWAP_32)
check_symbol_exists(bswap_64 byteswap.h HAVE_BSWAP_64)
tuklib_add_definition_if("${TARGET_OR_ALL}" HAVE_BSWAP_64)
else()
check_include_file(sys/endian.h HAVE_SYS_ENDIAN_H)
if(HAVE_SYS_ENDIAN_H)
tuklib_add_definitions("${TARGET_OR_ALL}" HAVE_SYS_ENDIAN_H)
else()
check_include_file(sys/byteorder.h HAVE_SYS_BYTEORDER_H)
tuklib_add_definition_if("${TARGET_OR_ALL}"
HAVE_SYS_BYTEORDER_H)
endif()
endif()
endif()
# Guess that unaligned access is fast on these archs:
# - 32/64-bit x86 / x86-64
# - 32/64-bit big endian PowerPC
# - 64-bit little endian PowerPC
# - Some 32-bit ARM
# - Some 64-bit ARM64 (AArch64)
# - Some 32/64-bit RISC-V
#
# CMake doesn't provide a standardized/normalized list of processor arch
# names. For example, x86-64 may be "x86_64" (Linux), "AMD64" (Windows),
# or even "EM64T" (64-bit WinXP).
set(FAST_UNALIGNED_GUESS OFF)
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" PROCESSOR)
# There is no ^ in the first regex branch to allow "i" at the beginning
# so it can match "i386" to "i786", and "x86_64".
if(PROCESSOR MATCHES "[x34567]86|^x64|^amd64|^em64t")
set(FAST_UNALIGNED_GUESS ON)
elseif(PROCESSOR MATCHES "^powerpc|^ppc")
if(WORDS_BIGENDIAN OR PROCESSOR MATCHES "64")
set(FAST_UNALIGNED_GUESS ON)
endif()
elseif(PROCESSOR MATCHES "^arm|^aarch64|^riscv")
# On 32-bit and 64-bit ARM, GCC and Clang
# #define __ARM_FEATURE_UNALIGNED if
# unaligned access is supported.
#
# Exception: GCC at least up to 13.2.0
# defines it even when using -mstrict-align
# so in that case this autodetection goes wrong.
# Most of the time -mstrict-align isn't used so it
# shouldn't be a common problem in practice. See:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111555
#
# RISC-V C API Specification says that if
# __riscv_misaligned_fast is defined then
# unaligned access is known to be fast.
#
# MSVC is handled as a special case: We assume that
# 32/64-bit ARM supports fast unaligned access.
# If MSVC gets RISC-V support then this will assume
# fast unaligned access on RISC-V too.
check_c_source_compiles("
#if !defined(__ARM_FEATURE_UNALIGNED) \
&& !defined(__riscv_misaligned_fast) \
&& !defined(_MSC_VER)
compile error
#endif
int main(void) { return 0; }
"
TUKLIB_FAST_UNALIGNED_DEFINED_BY_PREPROCESSOR)
if(TUKLIB_FAST_UNALIGNED_DEFINED_BY_PREPROCESSOR)
set(FAST_UNALIGNED_GUESS ON)
endif()
endif()
option(TUKLIB_FAST_UNALIGNED_ACCESS
"Enable if the system supports *fast* unaligned memory access \
with 16-bit, 32-bit, and 64-bit integers."
"${FAST_UNALIGNED_GUESS}")
tuklib_add_definition_if("${TARGET_OR_ALL}" TUKLIB_FAST_UNALIGNED_ACCESS)
# Unsafe type punning:
option(TUKLIB_USE_UNSAFE_TYPE_PUNNING
"This introduces strict aliasing violations and \
may result in broken code. However, this might improve performance \
in some cases, especially with old compilers \
(e.g. GCC 3 and early 4.x on x86, GCC < 6 on ARMv6 and ARMv7)."
OFF)
tuklib_add_definition_if("${TARGET_OR_ALL}" TUKLIB_USE_UNSAFE_TYPE_PUNNING)
# Check for GCC/Clang __builtin_assume_aligned().
check_c_source_compiles(
"int main(void) { __builtin_assume_aligned(\"\", 1); return 0; }"
HAVE___BUILTIN_ASSUME_ALIGNED)
tuklib_add_definition_if("${TARGET_OR_ALL}" HAVE___BUILTIN_ASSUME_ALIGNED)
endfunction()

View File

@ -0,0 +1,53 @@
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# tuklib_large_file_support.cmake
#
# If off_t is less than 64 bits by default and -D_FILE_OFFSET_BITS=64
# makes off_t become 64-bit, the CMake option LARGE_FILE_SUPPORT is
# provided (ON by default) and -D_FILE_OFFSET_BITS=64 is added to
# the compile definitions if LARGE_FILE_SUPPORT is ON.
#
# Author: Lasse Collin
#
#############################################################################
include("${CMAKE_CURRENT_LIST_DIR}/tuklib_common.cmake")
include(CheckCSourceCompiles)
function(tuklib_large_file_support TARGET_OR_ALL)
# MSVC must be handled specially in the C code.
if(MSVC)
return()
endif()
set(TUKLIB_LARGE_FILE_SUPPORT_TEST
"#include <sys/types.h>
int foo[sizeof(off_t) >= 8 ? 1 : -1];
int main(void) { return 0; }")
check_c_source_compiles("${TUKLIB_LARGE_FILE_SUPPORT_TEST}"
TUKLIB_LARGE_FILE_SUPPORT_BY_DEFAULT)
if(NOT TUKLIB_LARGE_FILE_SUPPORT_BY_DEFAULT)
cmake_push_check_state()
# This needs -D.
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_FILE_OFFSET_BITS=64")
check_c_source_compiles("${TUKLIB_LARGE_FILE_SUPPORT_TEST}"
TUKLIB_LARGE_FILE_SUPPORT_WITH_FOB64)
cmake_pop_check_state()
endif()
if(TUKLIB_LARGE_FILE_SUPPORT_WITH_FOB64)
# Show the option only when _FILE_OFFSET_BITS=64 affects sizeof(off_t).
option(LARGE_FILE_SUPPORT
"Use -D_FILE_OFFSET_BITS=64 to support files larger than 2 GiB."
ON)
if(LARGE_FILE_SUPPORT)
# This must not use -D.
tuklib_add_definitions("${TARGET_OR_ALL}" "_FILE_OFFSET_BITS=64")
endif()
endif()
endfunction()

21
cmake/tuklib_mbstr.cmake Normal file
View File

@ -0,0 +1,21 @@
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# tuklib_mbstr.cmake - see tuklib_mbstr.m4 for description and comments
#
# Author: Lasse Collin
#
#############################################################################
include("${CMAKE_CURRENT_LIST_DIR}/tuklib_common.cmake")
include(CheckSymbolExists)
function(tuklib_mbstr TARGET_OR_ALL)
check_symbol_exists(mbrtowc wchar.h HAVE_MBRTOWC)
tuklib_add_definition_if("${TARGET_OR_ALL}" HAVE_MBRTOWC)
# NOTE: wcwidth() requires _GNU_SOURCE or _XOPEN_SOURCE on GNU/Linux.
check_symbol_exists(wcwidth wchar.h HAVE_WCWIDTH)
tuklib_add_definition_if("${TARGET_OR_ALL}" HAVE_WCWIDTH)
endfunction()

151
cmake/tuklib_physmem.cmake Normal file
View File

@ -0,0 +1,151 @@
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# tuklib_physmem.cmake - see tuklib_physmem.m4 for description and comments
#
# NOTE: Compared tuklib_physmem.m4, this lacks support for Tru64, IRIX, and
# Linux sysinfo() (usually sysconf() is used on GNU/Linux).
#
# Author: Lasse Collin
#
#############################################################################
include("${CMAKE_CURRENT_LIST_DIR}/tuklib_common.cmake")
include(CheckCSourceCompiles)
include(CheckIncludeFile)
function(tuklib_physmem_internal_check)
# Shortcut on Windows:
if(WIN32 OR CYGWIN)
# Nothing to do, the tuklib_physmem.c handles it.
set(TUKLIB_PHYSMEM_DEFINITIONS "" CACHE INTERNAL "")
return()
endif()
# Full check for special cases:
check_c_source_compiles("
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__OS2__) \
|| defined(__DJGPP__) || defined(__VMS) \
|| defined(AMIGA) || defined(__AROS__) || defined(__QNX__)
int main(void) { return 0; }
#else
compile error
#endif
"
TUKLIB_PHYSMEM_SPECIAL)
if(TUKLIB_PHYSMEM_SPECIAL)
# Nothing to do, the tuklib_physmem.c handles it.
set(TUKLIB_PHYSMEM_DEFINITIONS "" CACHE INTERNAL "")
return()
endif()
# Look for AIX-specific solution before sysconf(), because the test
# for sysconf() will pass on AIX but won't actually work
# (sysconf(_SC_PHYS_PAGES) compiles but always returns -1 on AIX).
check_c_source_compiles("
#include <sys/systemcfg.h>
int main(void)
{
(void)_system_configuration.physmem;
return 0;
}
"
TUKLIB_PHYSMEM_AIX)
if(TUKLIB_PHYSMEM_AIX)
set(TUKLIB_PHYSMEM_DEFINITIONS "TUKLIB_PHYSMEM_AIX" CACHE INTERNAL "")
return()
endif()
# sysconf()
check_c_source_compiles("
#include <unistd.h>
int main(void)
{
long i;
i = sysconf(_SC_PAGESIZE);
i = sysconf(_SC_PHYS_PAGES);
return 0;
}
"
TUKLIB_PHYSMEM_SYSCONF)
if(TUKLIB_PHYSMEM_SYSCONF)
set(TUKLIB_PHYSMEM_DEFINITIONS "TUKLIB_PHYSMEM_SYSCONF"
CACHE INTERNAL "")
return()
endif()
# sysctl()
check_include_file(sys/param.h HAVE_SYS_PARAM_H)
if(HAVE_SYS_PARAM_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_PARAM_H)
endif()
check_c_source_compiles("
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
#include <sys/sysctl.h>
int main(void)
{
int name[2] = { CTL_HW, HW_PHYSMEM };
unsigned long mem;
size_t mem_ptr_size = sizeof(mem);
sysctl(name, 2, &mem, &mem_ptr_size, NULL, 0);
return 0;
}
"
TUKLIB_PHYSMEM_SYSCTL)
if(TUKLIB_PHYSMEM_SYSCTL)
if(HAVE_SYS_PARAM_H)
set(TUKLIB_PHYSMEM_DEFINITIONS
"HAVE_PARAM_H;TUKLIB_PHYSMEM_SYSCTL"
CACHE INTERNAL "")
else()
set(TUKLIB_PHYSMEM_DEFINITIONS
"TUKLIB_PHYSMEM_SYSCTL"
CACHE INTERNAL "")
endif()
return()
endif()
# HP-UX
check_c_source_compiles("
#include <sys/param.h>
#include <sys/pstat.h>
int main(void)
{
struct pst_static pst;
pstat_getstatic(&pst, sizeof(pst), 1, 0);
(void)pst.physical_memory;
(void)pst.page_size;
return 0;
}
"
TUKLIB_PHYSMEM_PSTAT_GETSTATIC)
if(TUKLIB_PHYSMEM_PSTAT_GETSTATIC)
set(TUKLIB_PHYSMEM_DEFINITIONS "TUKLIB_PHYSMEM_PSTAT_GETSTATIC"
CACHE INTERNAL "")
return()
endif()
endfunction()
function(tuklib_physmem TARGET_OR_ALL)
if(NOT DEFINED TUKLIB_PHYSMEM_FOUND)
message(STATUS "Checking how to detect the amount of physical memory")
tuklib_physmem_internal_check()
if(DEFINED TUKLIB_PHYSMEM_DEFINITIONS)
set(TUKLIB_PHYSMEM_FOUND 1 CACHE INTERNAL "")
else()
set(TUKLIB_PHYSMEM_FOUND 0 CACHE INTERNAL "")
message(WARNING
"No method to detect the amount of physical memory was found")
endif()
endif()
if(TUKLIB_PHYSMEM_FOUND)
tuklib_add_definitions("${TARGET_OR_ALL}"
"${TUKLIB_PHYSMEM_DEFINITIONS}")
endif()
endfunction()

View File

@ -0,0 +1,19 @@
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# tuklib_progname.cmake - see tuklib_progname.m4 for description and comments
#
# Author: Lasse Collin
#
#############################################################################
include("${CMAKE_CURRENT_LIST_DIR}/tuklib_common.cmake")
include(CheckSymbolExists)
function(tuklib_progname TARGET_OR_ALL)
# NOTE: This glibc extension requires _GNU_SOURCE.
check_symbol_exists(program_invocation_name errno.h
HAVE_PROGRAM_INVOCATION_NAME)
tuklib_add_definition_if("${TARGET_OR_ALL}" HAVE_PROGRAM_INVOCATION_NAME)
endfunction()

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,8 @@
##
## SPDX-License-Identifier: 0BSD
## Author: Lasse Collin
##
## This file has been put into the public domain.
## You can do whatever you want with this file.
##
EXTRA_DIST = \
translation.bash
noinst_PROGRAMS = \
repeat \

View File

@ -3,7 +3,7 @@ Debug tools
-----------
This directory contains a few tiny programs that may be helpful when
debugging LZMA Utils.
debugging XZ Utils.
These tools are not meant to be installed. Often one needs to edit
the source code a little to make the programs do the wanted things.

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: 0BSD
///////////////////////////////////////////////////////////////////////////////
//
/// \file crc32.c
@ -5,9 +7,6 @@
//
// Author: Lasse Collin
//
// This file has been put into the public domain.
// You can do whatever you want with this file.
//
///////////////////////////////////////////////////////////////////////////////
#include "sysdefs.h"

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: 0BSD
///////////////////////////////////////////////////////////////////////////////
//
/// \file full_flush.c
@ -5,15 +7,14 @@
//
// Author: Lasse Collin
//
// This file has been put into the public domain.
// You can do whatever you want with this file.
//
///////////////////////////////////////////////////////////////////////////////
#include "sysdefs.h"
#include "lzma.h"
#include <stdio.h>
#define CHUNK 64
static lzma_stream strm = LZMA_STREAM_INIT;
static FILE *file_in;
@ -22,7 +23,6 @@ static FILE *file_in;
static void
encode(size_t size, lzma_action action)
{
static const size_t CHUNK = 64;
uint8_t in[CHUNK];
uint8_t out[CHUNK];
lzma_ret ret;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: 0BSD
///////////////////////////////////////////////////////////////////////////////
//
/// \file hex2bin.c
@ -5,9 +7,6 @@
//
// Author: Lasse Collin
//
// This file has been put into the public domain.
// You can do whatever you want with this file.
//
///////////////////////////////////////////////////////////////////////////////
#include "sysdefs.h"

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: 0BSD
///////////////////////////////////////////////////////////////////////////////
//
/// \file known_sizes.c
@ -9,9 +11,6 @@
//
// Author: Lasse Collin
//
// This file has been put into the public domain.
// You can do whatever you want with this file.
//
///////////////////////////////////////////////////////////////////////////////
#include "sysdefs.h"

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: 0BSD
///////////////////////////////////////////////////////////////////////////////
//
/// \file memusage.c
@ -5,9 +7,6 @@
//
// Author: Lasse Collin
//
// This file has been put into the public domain.
// You can do whatever you want with this file.
//
///////////////////////////////////////////////////////////////////////////////
#include "sysdefs.h"

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: 0BSD
///////////////////////////////////////////////////////////////////////////////
//
/// \file repeat.c
@ -9,9 +11,6 @@
//
// Author: Lasse Collin
//
// This file has been put into the public domain.
// You can do whatever you want with this file.
//
///////////////////////////////////////////////////////////////////////////////
#include "sysdefs.h"

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: 0BSD
///////////////////////////////////////////////////////////////////////////////
//
/// \file sync_flush.c
@ -5,15 +7,14 @@
//
// Author: Lasse Collin
//
// This file has been put into the public domain.
// You can do whatever you want with this file.
//
///////////////////////////////////////////////////////////////////////////////
#include "sysdefs.h"
#include "lzma.h"
#include <stdio.h>
#define CHUNK 64
static lzma_stream strm = LZMA_STREAM_INIT;
static FILE *file_in;
@ -22,7 +23,6 @@ static FILE *file_in;
static void
encode(size_t size, lzma_action action)
{
static const size_t CHUNK = 64;
uint8_t in[CHUNK];
uint8_t out[CHUNK];
lzma_ret ret;

View File

@ -1,4 +1,5 @@
#!/bin/bash
# SPDX-License-Identifier: 0BSD
###############################################################################
#
@ -20,9 +21,6 @@
#
# Author: Lasse Collin
#
# This file has been put into the public domain.
# You can do whatever you want with this file.
#
###############################################################################
set -e

View File

@ -0,0 +1,31 @@
liblzma example programs
========================
Introduction
The examples are written so that the same comments aren't
repeated (much) in later files.
On POSIX systems, the examples should build by just typing "make".
The examples that use stdin or stdout don't set stdin and stdout
to binary mode. On systems where it matters (e.g. Windows) it is
possible that the examples won't work without modification.
List of examples
01_compress_easy.c Multi-call compression using
a compression preset
02_decompress.c Multi-call decompression
03_compress_custom.c Like 01_compress_easy.c but using
a custom filter chain
(x86 BCJ + LZMA2)
04_compress_easy_mt.c Multi-threaded multi-call
compression using a compression
preset

View File

@ -0,0 +1,296 @@
// SPDX-License-Identifier: 0BSD
///////////////////////////////////////////////////////////////////////////////
//
/// \file 01_compress_easy.c
/// \brief Compress from stdin to stdout in multi-call mode
///
/// Usage: ./01_compress_easy PRESET < INFILE > OUTFILE
///
/// Example: ./01_compress_easy 6 < foo > foo.xz
//
// Author: Lasse Collin
//
///////////////////////////////////////////////////////////////////////////////
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <lzma.h>
static void
show_usage_and_exit(const char *argv0)
{
fprintf(stderr, "Usage: %s PRESET < INFILE > OUTFILE\n"
"PRESET is a number 0-9 and can optionally be "
"followed by 'e' to indicate extreme preset\n",
argv0);
exit(EXIT_FAILURE);
}
static uint32_t
get_preset(int argc, char **argv)
{
// One argument whose first char must be 0-9.
if (argc != 2 || argv[1][0] < '0' || argv[1][0] > '9')
show_usage_and_exit(argv[0]);
// Calculate the preste level 0-9.
uint32_t preset = argv[1][0] - '0';
// If there is a second char, it must be 'e'. It will set
// the LZMA_PRESET_EXTREME flag.
if (argv[1][1] != '\0') {
if (argv[1][1] != 'e' || argv[1][2] != '\0')
show_usage_and_exit(argv[0]);
preset |= LZMA_PRESET_EXTREME;
}
return preset;
}
static bool
init_encoder(lzma_stream *strm, uint32_t preset)
{
// Initialize the encoder using a preset. Set the integrity to check
// to CRC64, which is the default in the xz command line tool. If
// the .xz file needs to be decompressed with XZ Embedded, use
// LZMA_CHECK_CRC32 instead.
lzma_ret ret = lzma_easy_encoder(strm, preset, LZMA_CHECK_CRC64);
// Return successfully if the initialization went fine.
if (ret == LZMA_OK)
return true;
// Something went wrong. The possible errors are documented in
// lzma/container.h (src/liblzma/api/lzma/container.h in the source
// package or e.g. /usr/include/lzma/container.h depending on the
// install prefix).
const char *msg;
switch (ret) {
case LZMA_MEM_ERROR:
msg = "Memory allocation failed";
break;
case LZMA_OPTIONS_ERROR:
msg = "Specified preset is not supported";
break;
case LZMA_UNSUPPORTED_CHECK:
msg = "Specified integrity check is not supported";
break;
default:
// This is most likely LZMA_PROG_ERROR indicating a bug in
// this program or in liblzma. It is inconvenient to have a
// separate error message for errors that should be impossible
// to occur, but knowing the error code is important for
// debugging. That's why it is good to print the error code
// at least when there is no good error message to show.
msg = "Unknown error, possibly a bug";
break;
}
fprintf(stderr, "Error initializing the encoder: %s (error code %u)\n",
msg, ret);
return false;
}
static bool
compress(lzma_stream *strm, FILE *infile, FILE *outfile)
{
// This will be LZMA_RUN until the end of the input file is reached.
// This tells lzma_code() when there will be no more input.
lzma_action action = LZMA_RUN;
// Buffers to temporarily hold uncompressed input
// and compressed output.
uint8_t inbuf[BUFSIZ];
uint8_t outbuf[BUFSIZ];
// Initialize the input and output pointers. Initializing next_in
// and avail_in isn't really necessary when we are going to encode
// just one file since LZMA_STREAM_INIT takes care of initializing
// those already. But it doesn't hurt much and it will be needed
// if encoding more than one file like we will in 02_decompress.c.
//
// While we don't care about strm->total_in or strm->total_out in this
// example, it is worth noting that initializing the encoder will
// always reset total_in and total_out to zero. But the encoder
// initialization doesn't touch next_in, avail_in, next_out, or
// avail_out.
strm->next_in = NULL;
strm->avail_in = 0;
strm->next_out = outbuf;
strm->avail_out = sizeof(outbuf);
// Loop until the file has been successfully compressed or until
// an error occurs.
while (true) {
// Fill the input buffer if it is empty.
if (strm->avail_in == 0 && !feof(infile)) {
strm->next_in = inbuf;
strm->avail_in = fread(inbuf, 1, sizeof(inbuf),
infile);
if (ferror(infile)) {
fprintf(stderr, "Read error: %s\n",
strerror(errno));
return false;
}
// Once the end of the input file has been reached,
// we need to tell lzma_code() that no more input
// will be coming and that it should finish the
// encoding.
if (feof(infile))
action = LZMA_FINISH;
}
// Tell liblzma do the actual encoding.
//
// This reads up to strm->avail_in bytes of input starting
// from strm->next_in. avail_in will be decremented and
// next_in incremented by an equal amount to match the
// number of input bytes consumed.
//
// Up to strm->avail_out bytes of compressed output will be
// written starting from strm->next_out. avail_out and next_out
// will be incremented by an equal amount to match the number
// of output bytes written.
//
// The encoder has to do internal buffering, which means that
// it may take quite a bit of input before the same data is
// available in compressed form in the output buffer.
lzma_ret ret = lzma_code(strm, action);
// If the output buffer is full or if the compression finished
// successfully, write the data from the output buffer to
// the output file.
if (strm->avail_out == 0 || ret == LZMA_STREAM_END) {
// When lzma_code() has returned LZMA_STREAM_END,
// the output buffer is likely to be only partially
// full. Calculate how much new data there is to
// be written to the output file.
size_t write_size = sizeof(outbuf) - strm->avail_out;
if (fwrite(outbuf, 1, write_size, outfile)
!= write_size) {
fprintf(stderr, "Write error: %s\n",
strerror(errno));
return false;
}
// Reset next_out and avail_out.
strm->next_out = outbuf;
strm->avail_out = sizeof(outbuf);
}
// Normally the return value of lzma_code() will be LZMA_OK
// until everything has been encoded.
if (ret != LZMA_OK) {
// Once everything has been encoded successfully, the
// return value of lzma_code() will be LZMA_STREAM_END.
//
// It is important to check for LZMA_STREAM_END. Do not
// assume that getting ret != LZMA_OK would mean that
// everything has gone well.
if (ret == LZMA_STREAM_END)
return true;
// It's not LZMA_OK nor LZMA_STREAM_END,
// so it must be an error code. See lzma/base.h
// (src/liblzma/api/lzma/base.h in the source package
// or e.g. /usr/include/lzma/base.h depending on the
// install prefix) for the list and documentation of
// possible values. Most values listen in lzma_ret
// enumeration aren't possible in this example.
const char *msg;
switch (ret) {
case LZMA_MEM_ERROR:
msg = "Memory allocation failed";
break;
case LZMA_DATA_ERROR:
// This error is returned if the compressed
// or uncompressed size get near 8 EiB
// (2^63 bytes) because that's where the .xz
// file format size limits currently are.
// That is, the possibility of this error
// is mostly theoretical unless you are doing
// something very unusual.
//
// Note that strm->total_in and strm->total_out
// have nothing to do with this error. Changing
// those variables won't increase or decrease
// the chance of getting this error.
msg = "File size limits exceeded";
break;
default:
// This is most likely LZMA_PROG_ERROR, but
// if this program is buggy (or liblzma has
// a bug), it may be e.g. LZMA_BUF_ERROR or
// LZMA_OPTIONS_ERROR too.
//
// It is inconvenient to have a separate
// error message for errors that should be
// impossible to occur, but knowing the error
// code is important for debugging. That's why
// it is good to print the error code at least
// when there is no good error message to show.
msg = "Unknown error, possibly a bug";
break;
}
fprintf(stderr, "Encoder error: %s (error code %u)\n",
msg, ret);
return false;
}
}
}
extern int
main(int argc, char **argv)
{
// Get the preset number from the command line.
uint32_t preset = get_preset(argc, argv);
// Initialize a lzma_stream structure. When it is allocated on stack,
// it is simplest to use LZMA_STREAM_INIT macro like below. When it
// is allocated on heap, using memset(strmptr, 0, sizeof(*strmptr))
// works (as long as NULL pointers are represented with zero bits
// as they are on practically all computers today).
lzma_stream strm = LZMA_STREAM_INIT;
// Initialize the encoder. If it succeeds, compress from
// stdin to stdout.
bool success = init_encoder(&strm, preset);
if (success)
success = compress(&strm, stdin, stdout);
// Free the memory allocated for the encoder. If we were encoding
// multiple files, this would only need to be done after the last
// file. See 02_decompress.c for handling of multiple files.
//
// It is OK to call lzma_end() multiple times or when it hasn't been
// actually used except initialized with LZMA_STREAM_INIT.
lzma_end(&strm);
// Close stdout to catch possible write errors that can occur
// when pending data is flushed from the stdio buffers.
if (fclose(stdout)) {
fprintf(stderr, "Write error: %s\n", strerror(errno));
success = false;
}
return success ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@ -0,0 +1,286 @@
// SPDX-License-Identifier: 0BSD
///////////////////////////////////////////////////////////////////////////////
//
/// \file 02_decompress.c
/// \brief Decompress .xz files to stdout
///
/// Usage: ./02_decompress INPUT_FILES... > OUTFILE
///
/// Example: ./02_decompress foo.xz bar.xz > foobar
//
// Author: Lasse Collin
//
///////////////////////////////////////////////////////////////////////////////
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <lzma.h>
static bool
init_decoder(lzma_stream *strm)
{
// Initialize a .xz decoder. The decoder supports a memory usage limit
// and a set of flags.
//
// The memory usage of the decompressor depends on the settings used
// to compress a .xz file. It can vary from less than a megabyte to
// a few gigabytes, but in practice (at least for now) it rarely
// exceeds 65 MiB because that's how much memory is required to
// decompress files created with "xz -9". Settings requiring more
// memory take extra effort to use and don't (at least for now)
// provide significantly better compression in most cases.
//
// Memory usage limit is useful if it is important that the
// decompressor won't consume gigabytes of memory. The need
// for limiting depends on the application. In this example,
// no memory usage limiting is used. This is done by setting
// the limit to UINT64_MAX.
//
// The .xz format allows concatenating compressed files as is:
//
// echo foo | xz > foobar.xz
// echo bar | xz >> foobar.xz
//
// When decompressing normal standalone .xz files, LZMA_CONCATENATED
// should always be used to support decompression of concatenated
// .xz files. If LZMA_CONCATENATED isn't used, the decoder will stop
// after the first .xz stream. This can be useful when .xz data has
// been embedded inside another file format.
//
// Flags other than LZMA_CONCATENATED are supported too, and can
// be combined with bitwise-or. See lzma/container.h
// (src/liblzma/api/lzma/container.h in the source package or e.g.
// /usr/include/lzma/container.h depending on the install prefix)
// for details.
lzma_ret ret = lzma_stream_decoder(
strm, UINT64_MAX, LZMA_CONCATENATED);
// Return successfully if the initialization went fine.
if (ret == LZMA_OK)
return true;
// Something went wrong. The possible errors are documented in
// lzma/container.h (src/liblzma/api/lzma/container.h in the source
// package or e.g. /usr/include/lzma/container.h depending on the
// install prefix).
//
// Note that LZMA_MEMLIMIT_ERROR is never possible here. If you
// specify a very tiny limit, the error will be delayed until
// the first headers have been parsed by a call to lzma_code().
const char *msg;
switch (ret) {
case LZMA_MEM_ERROR:
msg = "Memory allocation failed";
break;
case LZMA_OPTIONS_ERROR:
msg = "Unsupported decompressor flags";
break;
default:
// This is most likely LZMA_PROG_ERROR indicating a bug in
// this program or in liblzma. It is inconvenient to have a
// separate error message for errors that should be impossible
// to occur, but knowing the error code is important for
// debugging. That's why it is good to print the error code
// at least when there is no good error message to show.
msg = "Unknown error, possibly a bug";
break;
}
fprintf(stderr, "Error initializing the decoder: %s (error code %u)\n",
msg, ret);
return false;
}
static bool
decompress(lzma_stream *strm, const char *inname, FILE *infile, FILE *outfile)
{
// When LZMA_CONCATENATED flag was used when initializing the decoder,
// we need to tell lzma_code() when there will be no more input.
// This is done by setting action to LZMA_FINISH instead of LZMA_RUN
// in the same way as it is done when encoding.
//
// When LZMA_CONCATENATED isn't used, there is no need to use
// LZMA_FINISH to tell when all the input has been read, but it
// is still OK to use it if you want. When LZMA_CONCATENATED isn't
// used, the decoder will stop after the first .xz stream. In that
// case some unused data may be left in strm->next_in.
lzma_action action = LZMA_RUN;
uint8_t inbuf[BUFSIZ];
uint8_t outbuf[BUFSIZ];
strm->next_in = NULL;
strm->avail_in = 0;
strm->next_out = outbuf;
strm->avail_out = sizeof(outbuf);
while (true) {
if (strm->avail_in == 0 && !feof(infile)) {
strm->next_in = inbuf;
strm->avail_in = fread(inbuf, 1, sizeof(inbuf),
infile);
if (ferror(infile)) {
fprintf(stderr, "%s: Read error: %s\n",
inname, strerror(errno));
return false;
}
// Once the end of the input file has been reached,
// we need to tell lzma_code() that no more input
// will be coming. As said before, this isn't required
// if the LZMA_CONCATENATED flag isn't used when
// initializing the decoder.
if (feof(infile))
action = LZMA_FINISH;
}
lzma_ret ret = lzma_code(strm, action);
if (strm->avail_out == 0 || ret == LZMA_STREAM_END) {
size_t write_size = sizeof(outbuf) - strm->avail_out;
if (fwrite(outbuf, 1, write_size, outfile)
!= write_size) {
fprintf(stderr, "Write error: %s\n",
strerror(errno));
return false;
}
strm->next_out = outbuf;
strm->avail_out = sizeof(outbuf);
}
if (ret != LZMA_OK) {
// Once everything has been decoded successfully, the
// return value of lzma_code() will be LZMA_STREAM_END.
//
// It is important to check for LZMA_STREAM_END. Do not
// assume that getting ret != LZMA_OK would mean that
// everything has gone well or that when you aren't
// getting more output it must have successfully
// decoded everything.
if (ret == LZMA_STREAM_END)
return true;
// It's not LZMA_OK nor LZMA_STREAM_END,
// so it must be an error code. See lzma/base.h
// (src/liblzma/api/lzma/base.h in the source package
// or e.g. /usr/include/lzma/base.h depending on the
// install prefix) for the list and documentation of
// possible values. Many values listen in lzma_ret
// enumeration aren't possible in this example, but
// can be made possible by enabling memory usage limit
// or adding flags to the decoder initialization.
const char *msg;
switch (ret) {
case LZMA_MEM_ERROR:
msg = "Memory allocation failed";
break;
case LZMA_FORMAT_ERROR:
// .xz magic bytes weren't found.
msg = "The input is not in the .xz format";
break;
case LZMA_OPTIONS_ERROR:
// For example, the headers specify a filter
// that isn't supported by this liblzma
// version (or it hasn't been enabled when
// building liblzma, but no-one sane does
// that unless building liblzma for an
// embedded system). Upgrading to a newer
// liblzma might help.
//
// Note that it is unlikely that the file has
// accidentally became corrupt if you get this
// error. The integrity of the .xz headers is
// always verified with a CRC32, so
// unintentionally corrupt files can be
// distinguished from unsupported files.
msg = "Unsupported compression options";
break;
case LZMA_DATA_ERROR:
msg = "Compressed file is corrupt";
break;
case LZMA_BUF_ERROR:
// Typically this error means that a valid
// file has got truncated, but it might also
// be a damaged part in the file that makes
// the decoder think the file is truncated.
// If you prefer, you can use the same error
// message for this as for LZMA_DATA_ERROR.
msg = "Compressed file is truncated or "
"otherwise corrupt";
break;
default:
// This is most likely LZMA_PROG_ERROR.
msg = "Unknown error, possibly a bug";
break;
}
fprintf(stderr, "%s: Decoder error: "
"%s (error code %u)\n",
inname, msg, ret);
return false;
}
}
}
extern int
main(int argc, char **argv)
{
if (argc <= 1) {
fprintf(stderr, "Usage: %s FILES...\n", argv[0]);
return EXIT_FAILURE;
}
lzma_stream strm = LZMA_STREAM_INIT;
bool success = true;
// Try to decompress all files.
for (int i = 1; i < argc; ++i) {
if (!init_decoder(&strm)) {
// Decoder initialization failed. There's no point
// to retry it so we need to exit.
success = false;
break;
}
FILE *infile = fopen(argv[i], "rb");
if (infile == NULL) {
fprintf(stderr, "%s: Error opening the "
"input file: %s\n",
argv[i], strerror(errno));
success = false;
} else {
success &= decompress(&strm, argv[i], infile, stdout);
fclose(infile);
}
}
// Free the memory allocated for the decoder. This only needs to be
// done after the last file.
lzma_end(&strm);
if (fclose(stdout)) {
fprintf(stderr, "Write error: %s\n", strerror(errno));
success = false;
}
return success ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@ -0,0 +1,192 @@
// SPDX-License-Identifier: 0BSD
///////////////////////////////////////////////////////////////////////////////
//
/// \file 03_compress_custom.c
/// \brief Compress in multi-call mode using x86 BCJ and LZMA2
///
/// Usage: ./03_compress_custom < INFILE > OUTFILE
///
/// Example: ./03_compress_custom < foo > foo.xz
//
// Author: Lasse Collin
//
///////////////////////////////////////////////////////////////////////////////
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <lzma.h>
static bool
init_encoder(lzma_stream *strm)
{
// Use the default preset (6) for LZMA2.
//
// The lzma_options_lzma structure and the lzma_lzma_preset() function
// are declared in lzma/lzma12.h (src/liblzma/api/lzma/lzma12.h in the
// source package or e.g. /usr/include/lzma/lzma12.h depending on
// the install prefix).
lzma_options_lzma opt_lzma2;
if (lzma_lzma_preset(&opt_lzma2, LZMA_PRESET_DEFAULT)) {
// It should never fail because the default preset
// (and presets 0-9 optionally with LZMA_PRESET_EXTREME)
// are supported by all stable liblzma versions.
//
// (The encoder initialization later in this function may
// still fail due to unsupported preset *if* the features
// required by the preset have been disabled at build time,
// but no-one does such things except on embedded systems.)
fprintf(stderr, "Unsupported preset, possibly a bug\n");
return false;
}
// Now we could customize the LZMA2 options if we wanted. For example,
// we could set the the dictionary size (opt_lzma2.dict_size) to
// something else than the default (8 MiB) of the default preset.
// See lzma/lzma12.h for details of all LZMA2 options.
//
// The x86 BCJ filter will try to modify the x86 instruction stream so
// that LZMA2 can compress it better. The x86 BCJ filter doesn't need
// any options so it will be set to NULL below.
//
// Construct the filter chain. The uncompressed data goes first to
// the first filter in the array, in this case the x86 BCJ filter.
// The array is always terminated by setting .id = LZMA_VLI_UNKNOWN.
//
// See lzma/filter.h for more information about the lzma_filter
// structure.
lzma_filter filters[] = {
{ .id = LZMA_FILTER_X86, .options = NULL },
{ .id = LZMA_FILTER_LZMA2, .options = &opt_lzma2 },
{ .id = LZMA_VLI_UNKNOWN, .options = NULL },
};
// Initialize the encoder using the custom filter chain.
lzma_ret ret = lzma_stream_encoder(strm, filters, LZMA_CHECK_CRC64);
if (ret == LZMA_OK)
return true;
const char *msg;
switch (ret) {
case LZMA_MEM_ERROR:
msg = "Memory allocation failed";
break;
case LZMA_OPTIONS_ERROR:
// We are no longer using a plain preset so this error
// message has been edited accordingly compared to
// 01_compress_easy.c.
msg = "Specified filter chain is not supported";
break;
case LZMA_UNSUPPORTED_CHECK:
msg = "Specified integrity check is not supported";
break;
default:
msg = "Unknown error, possibly a bug";
break;
}
fprintf(stderr, "Error initializing the encoder: %s (error code %u)\n",
msg, ret);
return false;
}
// This function is identical to the one in 01_compress_easy.c.
static bool
compress(lzma_stream *strm, FILE *infile, FILE *outfile)
{
lzma_action action = LZMA_RUN;
uint8_t inbuf[BUFSIZ];
uint8_t outbuf[BUFSIZ];
strm->next_in = NULL;
strm->avail_in = 0;
strm->next_out = outbuf;
strm->avail_out = sizeof(outbuf);
while (true) {
if (strm->avail_in == 0 && !feof(infile)) {
strm->next_in = inbuf;
strm->avail_in = fread(inbuf, 1, sizeof(inbuf),
infile);
if (ferror(infile)) {
fprintf(stderr, "Read error: %s\n",
strerror(errno));
return false;
}
if (feof(infile))
action = LZMA_FINISH;
}
lzma_ret ret = lzma_code(strm, action);
if (strm->avail_out == 0 || ret == LZMA_STREAM_END) {
size_t write_size = sizeof(outbuf) - strm->avail_out;
if (fwrite(outbuf, 1, write_size, outfile)
!= write_size) {
fprintf(stderr, "Write error: %s\n",
strerror(errno));
return false;
}
strm->next_out = outbuf;
strm->avail_out = sizeof(outbuf);
}
if (ret != LZMA_OK) {
if (ret == LZMA_STREAM_END)
return true;
const char *msg;
switch (ret) {
case LZMA_MEM_ERROR:
msg = "Memory allocation failed";
break;
case LZMA_DATA_ERROR:
msg = "File size limits exceeded";
break;
default:
msg = "Unknown error, possibly a bug";
break;
}
fprintf(stderr, "Encoder error: %s (error code %u)\n",
msg, ret);
return false;
}
}
}
extern int
main(void)
{
lzma_stream strm = LZMA_STREAM_INIT;
bool success = init_encoder(&strm);
if (success)
success = compress(&strm, stdin, stdout);
lzma_end(&strm);
if (fclose(stdout)) {
fprintf(stderr, "Write error: %s\n", strerror(errno));
success = false;
}
return success ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@ -0,0 +1,205 @@
// SPDX-License-Identifier: 0BSD
///////////////////////////////////////////////////////////////////////////////
//
/// \file 04_compress_easy_mt.c
/// \brief Compress in multi-call mode using LZMA2 in multi-threaded mode
///
/// Usage: ./04_compress_easy_mt < INFILE > OUTFILE
///
/// Example: ./04_compress_easy_mt < foo > foo.xz
//
// Author: Lasse Collin
//
///////////////////////////////////////////////////////////////////////////////
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <lzma.h>
static bool
init_encoder(lzma_stream *strm)
{
// The threaded encoder takes the options as pointer to
// a lzma_mt structure.
lzma_mt mt = {
// No flags are needed.
.flags = 0,
// Let liblzma determine a sane block size.
.block_size = 0,
// Use no timeout for lzma_code() calls by setting timeout
// to zero. That is, sometimes lzma_code() might block for
// a long time (from several seconds to even minutes).
// If this is not OK, for example due to progress indicator
// needing updates, specify a timeout in milliseconds here.
// See the documentation of lzma_mt in lzma/container.h for
// information how to choose a reasonable timeout.
.timeout = 0,
// Use the default preset (6) for LZMA2.
// To use a preset, filters must be set to NULL.
.preset = LZMA_PRESET_DEFAULT,
.filters = NULL,
// Use CRC64 for integrity checking. See also
// 01_compress_easy.c about choosing the integrity check.
.check = LZMA_CHECK_CRC64,
};
// Detect how many threads the CPU supports.
mt.threads = lzma_cputhreads();
// If the number of CPU cores/threads cannot be detected,
// use one thread. Note that this isn't the same as the normal
// single-threaded mode as this will still split the data into
// blocks and use more RAM than the normal single-threaded mode.
// You may want to consider using lzma_easy_encoder() or
// lzma_stream_encoder() instead of lzma_stream_encoder_mt() if
// lzma_cputhreads() returns 0 or 1.
if (mt.threads == 0)
mt.threads = 1;
// If the number of CPU cores/threads exceeds threads_max,
// limit the number of threads to keep memory usage lower.
// The number 8 is arbitrarily chosen and may be too low or
// high depending on the compression preset and the computer
// being used.
//
// FIXME: A better way could be to check the amount of RAM
// (or available RAM) and use lzma_stream_encoder_mt_memusage()
// to determine if the number of threads should be reduced.
const uint32_t threads_max = 8;
if (mt.threads > threads_max)
mt.threads = threads_max;
// Initialize the threaded encoder.
lzma_ret ret = lzma_stream_encoder_mt(strm, &mt);
if (ret == LZMA_OK)
return true;
const char *msg;
switch (ret) {
case LZMA_MEM_ERROR:
msg = "Memory allocation failed";
break;
case LZMA_OPTIONS_ERROR:
// We are no longer using a plain preset so this error
// message has been edited accordingly compared to
// 01_compress_easy.c.
msg = "Specified filter chain is not supported";
break;
case LZMA_UNSUPPORTED_CHECK:
msg = "Specified integrity check is not supported";
break;
default:
msg = "Unknown error, possibly a bug";
break;
}
fprintf(stderr, "Error initializing the encoder: %s (error code %u)\n",
msg, ret);
return false;
}
// This function is identical to the one in 01_compress_easy.c.
static bool
compress(lzma_stream *strm, FILE *infile, FILE *outfile)
{
lzma_action action = LZMA_RUN;
uint8_t inbuf[BUFSIZ];
uint8_t outbuf[BUFSIZ];
strm->next_in = NULL;
strm->avail_in = 0;
strm->next_out = outbuf;
strm->avail_out = sizeof(outbuf);
while (true) {
if (strm->avail_in == 0 && !feof(infile)) {
strm->next_in = inbuf;
strm->avail_in = fread(inbuf, 1, sizeof(inbuf),
infile);
if (ferror(infile)) {
fprintf(stderr, "Read error: %s\n",
strerror(errno));
return false;
}
if (feof(infile))
action = LZMA_FINISH;
}
lzma_ret ret = lzma_code(strm, action);
if (strm->avail_out == 0 || ret == LZMA_STREAM_END) {
size_t write_size = sizeof(outbuf) - strm->avail_out;
if (fwrite(outbuf, 1, write_size, outfile)
!= write_size) {
fprintf(stderr, "Write error: %s\n",
strerror(errno));
return false;
}
strm->next_out = outbuf;
strm->avail_out = sizeof(outbuf);
}
if (ret != LZMA_OK) {
if (ret == LZMA_STREAM_END)
return true;
const char *msg;
switch (ret) {
case LZMA_MEM_ERROR:
msg = "Memory allocation failed";
break;
case LZMA_DATA_ERROR:
msg = "File size limits exceeded";
break;
default:
msg = "Unknown error, possibly a bug";
break;
}
fprintf(stderr, "Encoder error: %s (error code %u)\n",
msg, ret);
return false;
}
}
}
extern int
main(void)
{
lzma_stream strm = LZMA_STREAM_INIT;
bool success = init_encoder(&strm);
if (success)
success = compress(&strm, stdin, stdout);
lzma_end(&strm);
if (fclose(stdout)) {
fprintf(stderr, "Write error: %s\n", strerror(errno));
success = false;
}
return success ? EXIT_SUCCESS : EXIT_FAILURE;
}

205
doc/examples/11_file_info.c Normal file
View File

@ -0,0 +1,205 @@
// SPDX-License-Identifier: 0BSD
///////////////////////////////////////////////////////////////////////////////
//
/// \file 11_file_info.c
/// \brief Get uncompressed size of .xz file(s)
///
/// Usage: ./11_file_info INFILE1.xz [INFILEn.xz]...
///
/// Example: ./11_file_info foo.xz
//
// Author: Lasse Collin
//
///////////////////////////////////////////////////////////////////////////////
#include <stdbool.h>
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <lzma.h>
static bool
print_file_size(lzma_stream *strm, FILE *infile, const char *filename)
{
// Get the file size. In standard C it can be done by seeking to
// the end of the file and then getting the file position.
// In POSIX one can use fstat() and then st_size from struct stat.
// Also note that fseek() and ftell() use long and thus don't support
// large files on 32-bit systems (POSIX versions fseeko() and
// ftello() can support large files).
if (fseek(infile, 0, SEEK_END)) {
fprintf(stderr, "Error seeking the file '%s': %s\n",
filename, strerror(errno));
return false;
}
const long file_size = ftell(infile);
// The decoder wants to start from the beginning of the .xz file.
rewind(infile);
// Initialize the decoder.
lzma_index *i;
lzma_ret ret = lzma_file_info_decoder(strm, &i, UINT64_MAX,
(uint64_t)file_size);
switch (ret) {
case LZMA_OK:
// Initialization succeeded.
break;
case LZMA_MEM_ERROR:
fprintf(stderr, "Out of memory when initializing "
"the .xz file info decoder\n");
return false;
case LZMA_PROG_ERROR:
default:
fprintf(stderr, "Unknown error, possibly a bug\n");
return false;
}
// This example program reuses the same lzma_stream structure
// for multiple files, so we need to reset this when starting
// a new file.
strm->avail_in = 0;
// Buffer for input data.
uint8_t inbuf[BUFSIZ];
// Pass data to the decoder and seek when needed.
while (true) {
if (strm->avail_in == 0) {
strm->next_in = inbuf;
strm->avail_in = fread(inbuf, 1, sizeof(inbuf),
infile);
if (ferror(infile)) {
fprintf(stderr,
"Error reading from '%s': %s\n",
filename, strerror(errno));
return false;
}
// We don't need to care about hitting the end of
// the file so no need to check for feof().
}
ret = lzma_code(strm, LZMA_RUN);
switch (ret) {
case LZMA_OK:
break;
case LZMA_SEEK_NEEDED:
// The cast is safe because liblzma won't ask us to
// seek past the known size of the input file which
// did fit into a long.
//
// NOTE: Remember to change these to off_t if you
// switch fseeko() or lseek().
if (fseek(infile, (long)(strm->seek_pos), SEEK_SET)) {
fprintf(stderr, "Error seeking the "
"file '%s': %s\n",
filename, strerror(errno));
return false;
}
// The old data in the inbuf is useless now. Set
// avail_in to zero so that we will read new input
// from the new file position on the next iteration
// of this loop.
strm->avail_in = 0;
break;
case LZMA_STREAM_END:
// File information was successfully decoded.
// See <lzma/index.h> for functions that can be
// used on it. In this example we just print
// the uncompressed size (in bytes) of
// the .xz file followed by its file name.
printf("%10" PRIu64 " %s\n",
lzma_index_uncompressed_size(i),
filename);
// Free the memory of the lzma_index structure.
lzma_index_end(i, NULL);
return true;
case LZMA_FORMAT_ERROR:
// .xz magic bytes weren't found.
fprintf(stderr, "The file '%s' is not "
"in the .xz format\n", filename);
return false;
case LZMA_OPTIONS_ERROR:
fprintf(stderr, "The file '%s' has .xz headers that "
"are not supported by this liblzma "
"version\n", filename);
return false;
case LZMA_DATA_ERROR:
fprintf(stderr, "The file '%s' is corrupt\n",
filename);
return false;
case LZMA_MEM_ERROR:
fprintf(stderr, "Memory allocation failed when "
"decoding the file '%s'\n", filename);
return false;
// LZMA_MEMLIMIT_ERROR shouldn't happen because we used
// UINT64_MAX as the limit.
//
// LZMA_BUF_ERROR shouldn't happen because we always provide
// new input when the input buffer is empty. The decoder
// knows the input file size and thus won't try to read past
// the end of the file.
case LZMA_MEMLIMIT_ERROR:
case LZMA_BUF_ERROR:
case LZMA_PROG_ERROR:
default:
fprintf(stderr, "Unknown error, possibly a bug\n");
return false;
}
}
// This line is never reached.
}
extern int
main(int argc, char **argv)
{
bool success = true;
lzma_stream strm = LZMA_STREAM_INIT;
for (int i = 1; i < argc; ++i) {
FILE *infile = fopen(argv[i], "rb");
if (infile == NULL) {
fprintf(stderr, "Cannot open the file '%s': %s\n",
argv[i], strerror(errno));
success = false;
}
success &= print_file_size(&strm, infile, argv[i]);
(void)fclose(infile);
}
lzma_end(&strm);
// Close stdout to catch possible write errors that can occur
// when pending data is flushed from the stdio buffers.
if (fclose(stdout)) {
fprintf(stderr, "Write error: %s\n", strerror(errno));
success = false;
}
return success ? EXIT_SUCCESS : EXIT_FAILURE;
}

21
doc/examples/Makefile Normal file
View File

@ -0,0 +1,21 @@
# SPDX-License-Identifier: 0BSD
# Author: Lasse Collin
CC = c99
CFLAGS = -g
LDFLAGS = -llzma
PROGS = \
01_compress_easy \
02_decompress \
03_compress_custom \
04_compress_easy_mt \
11_file_info
all: $(PROGS)
.c:
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
clean:
-rm -f $(PROGS)

View File

@ -1,127 +0,0 @@
/*
* xz_pipe_comp.c
* A simple example of pipe-only xz compressor implementation.
* version: 2010-07-12 - by Daniel Mealha Cabrita
* Not copyrighted -- provided to the public domain.
*
* Compiling:
* Link with liblzma. GCC example:
* $ gcc -llzma xz_pipe_comp.c -o xz_pipe_comp
*
* Usage example:
* $ cat some_file | ./xz_pipe_comp > some_file.xz
*/
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdbool.h>
#include <lzma.h>
/* COMPRESSION SETTINGS */
/* analogous to xz CLI options: -0 to -9 */
#define COMPRESSION_LEVEL 6
/* boolean setting, analogous to xz CLI option: -e */
#define COMPRESSION_EXTREME true
/* see: /usr/include/lzma/check.h LZMA_CHECK_* */
#define INTEGRITY_CHECK LZMA_CHECK_CRC64
/* read/write buffer sizes */
#define IN_BUF_MAX 4096
#define OUT_BUF_MAX 4096
/* error codes */
#define RET_OK 0
#define RET_ERROR_INIT 1
#define RET_ERROR_INPUT 2
#define RET_ERROR_OUTPUT 3
#define RET_ERROR_COMPRESSION 4
/* note: in_file and out_file must be open already */
int xz_compress (FILE *in_file, FILE *out_file)
{
uint32_t preset = COMPRESSION_LEVEL | (COMPRESSION_EXTREME ? LZMA_PRESET_EXTREME : 0);
lzma_check check = INTEGRITY_CHECK;
lzma_stream strm = LZMA_STREAM_INIT; /* alloc and init lzma_stream struct */
uint8_t in_buf [IN_BUF_MAX];
uint8_t out_buf [OUT_BUF_MAX];
size_t in_len; /* length of useful data in in_buf */
size_t out_len; /* length of useful data in out_buf */
bool in_finished = false;
bool out_finished = false;
lzma_action action;
lzma_ret ret_xz;
int ret;
ret = RET_OK;
/* initialize xz encoder */
ret_xz = lzma_easy_encoder (&strm, preset, check);
if (ret_xz != LZMA_OK) {
fprintf (stderr, "lzma_easy_encoder error: %d\n", (int) ret_xz);
return RET_ERROR_INIT;
}
while ((! in_finished) && (! out_finished)) {
/* read incoming data */
in_len = fread (in_buf, 1, IN_BUF_MAX, in_file);
if (feof (in_file)) {
in_finished = true;
}
if (ferror (in_file)) {
in_finished = true;
ret = RET_ERROR_INPUT;
}
strm.next_in = in_buf;
strm.avail_in = in_len;
/* if no more data from in_buf, flushes the
internal xz buffers and closes the xz data
with LZMA_FINISH */
action = in_finished ? LZMA_FINISH : LZMA_RUN;
/* loop until there's no pending compressed output */
do {
/* out_buf is clean at this point */
strm.next_out = out_buf;
strm.avail_out = OUT_BUF_MAX;
/* compress data */
ret_xz = lzma_code (&strm, action);
if ((ret_xz != LZMA_OK) && (ret_xz != LZMA_STREAM_END)) {
fprintf (stderr, "lzma_code error: %d\n", (int) ret_xz);
out_finished = true;
ret = RET_ERROR_COMPRESSION;
} else {
/* write compressed data */
out_len = OUT_BUF_MAX - strm.avail_out;
fwrite (out_buf, 1, out_len, out_file);
if (ferror (out_file)) {
out_finished = true;
ret = RET_ERROR_OUTPUT;
}
}
} while (strm.avail_out == 0);
}
lzma_end (&strm);
return ret;
}
int main ()
{
int ret;
ret = xz_compress (stdin, stdout);
return ret;
}

View File

@ -1,115 +0,0 @@
/*
* xz_pipe_decomp.c
* A simple example of pipe-only xz decompressor implementation.
* version: 2010-07-12 - by Daniel Mealha Cabrita
* Not copyrighted -- provided to the public domain.
*
* Compiling:
* Link with liblzma. GCC example:
* $ gcc -llzma xz_pipe_decomp.c -o xz_pipe_decomp
*
* Usage example:
* $ cat some_file.xz | ./xz_pipe_decomp > some_file
*/
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdbool.h>
#include <lzma.h>
/* read/write buffer sizes */
#define IN_BUF_MAX 4096
#define OUT_BUF_MAX 4096
/* error codes */
#define RET_OK 0
#define RET_ERROR_INIT 1
#define RET_ERROR_INPUT 2
#define RET_ERROR_OUTPUT 3
#define RET_ERROR_DECOMPRESSION 4
/* note: in_file and out_file must be open already */
int xz_decompress (FILE *in_file, FILE *out_file)
{
lzma_stream strm = LZMA_STREAM_INIT; /* alloc and init lzma_stream struct */
const uint32_t flags = LZMA_TELL_UNSUPPORTED_CHECK | LZMA_CONCATENATED;
const uint64_t memory_limit = UINT64_MAX; /* no memory limit */
uint8_t in_buf [IN_BUF_MAX];
uint8_t out_buf [OUT_BUF_MAX];
size_t in_len; /* length of useful data in in_buf */
size_t out_len; /* length of useful data in out_buf */
bool in_finished = false;
bool out_finished = false;
lzma_action action;
lzma_ret ret_xz;
int ret;
ret = RET_OK;
/* initialize xz decoder */
ret_xz = lzma_stream_decoder (&strm, memory_limit, flags);
if (ret_xz != LZMA_OK) {
fprintf (stderr, "lzma_stream_decoder error: %d\n", (int) ret_xz);
return RET_ERROR_INIT;
}
while ((! in_finished) && (! out_finished)) {
/* read incoming data */
in_len = fread (in_buf, 1, IN_BUF_MAX, in_file);
if (feof (in_file)) {
in_finished = true;
}
if (ferror (in_file)) {
in_finished = true;
ret = RET_ERROR_INPUT;
}
strm.next_in = in_buf;
strm.avail_in = in_len;
/* if no more data from in_buf, flushes the
internal xz buffers and closes the decompressed data
with LZMA_FINISH */
action = in_finished ? LZMA_FINISH : LZMA_RUN;
/* loop until there's no pending decompressed output */
do {
/* out_buf is clean at this point */
strm.next_out = out_buf;
strm.avail_out = OUT_BUF_MAX;
/* decompress data */
ret_xz = lzma_code (&strm, action);
if ((ret_xz != LZMA_OK) && (ret_xz != LZMA_STREAM_END)) {
fprintf (stderr, "lzma_code error: %d\n", (int) ret_xz);
out_finished = true;
ret = RET_ERROR_DECOMPRESSION;
} else {
/* write decompressed data */
out_len = OUT_BUF_MAX - strm.avail_out;
fwrite (out_buf, 1, out_len, out_file);
if (ferror (out_file)) {
out_finished = true;
ret = RET_ERROR_OUTPUT;
}
}
} while (strm.avail_out == 0);
}
lzma_end (&strm);
return ret;
}
int main ()
{
int ret;
ret = xz_decompress (stdin, stdout);
return ret;
}

View File

@ -26,14 +26,14 @@ Q: There are many LZMA related projects. How does XZ Utils relate to them?
A: 7-Zip and LZMA SDK are the original projects. LZMA SDK is roughly
a subset of the 7-Zip source tree.
p7zip is 7-Zip's command line tools ported to POSIX-like systems.
p7zip is 7-Zip's command-line tools ported to POSIX-like systems.
LZMA Utils provide a gzip-like lzma tool for POSIX-like systems.
LZMA Utils are based on LZMA SDK. XZ Utils are the successor to
LZMA Utils.
There are several other projects using LZMA. Most are more or less
based on LZMA SDK. See <http://7-zip.org/links.html>.
based on LZMA SDK. See <https://7-zip.org/links.html>.
Q: Why is liblzma named liblzma if its primary file format is .xz?
@ -42,7 +42,7 @@ Q: Why is liblzma named liblzma if its primary file format is .xz?
A: When the designing of the .xz format began, the idea was to replace
the .lzma format and use the same .lzma suffix. It would have been
quite OK to reuse the suffix when there were very few .lzma files
around. However, the old .lzma format become popular before the
around. However, the old .lzma format became popular before the
new format was finished. The new format was renamed to .xz but the
name of liblzma wasn't changed.
@ -73,7 +73,7 @@ A: For now, no. Since XZ Utils supports the .lzma format, it's usually
Technically, there is a way to make the conversion relatively fast
(roughly twice the time that normal decompression takes). Writing
such a tool would take quite a bit time though, and would probably
such a tool would take quite a bit of time though, and would probably
be useful to only a few people. If you really want such a conversion
tool, contact Lasse Collin and offer some money.
@ -84,7 +84,7 @@ Q: I have installed xz, but my tar doesn't recognize .tar.xz files.
A: xz -dc foo.tar.xz | tar xf -
Q: Can I recover parts of a broken .xz file (e.g. corrupted CD-R)?
Q: Can I recover parts of a broken .xz file (e.g. a corrupted CD-R)?
A: It may be possible if the file consists of multiple blocks, which
typically is not the case if the file was created in single-threaded
@ -94,7 +94,7 @@ A: It may be possible if the file consists of multiple blocks, which
Q: Is (some part of) XZ Utils patented?
A: Lasse Collin is not aware of any patents that could affect XZ Utils.
However, due to nature of software patents, it's not possible to
However, due to the nature of software patents, it's not possible to
guarantee that XZ Utils isn't affected by any third party patent(s).
@ -105,8 +105,8 @@ A: The .xz format is documented in xz-file-format.txt. It is a container
filters.
Documenting LZMA and LZMA2 is planned, but for now, there is no other
documentation that the source code. Before you begin, you should know
the basics of LZ77 and range coding algorithms. LZMA is based on LZ77,
documentation than the source code. Before you begin, you should know
the basics of LZ77 and range-coding algorithms. LZMA is based on LZ77,
but LZMA is a lot more complex. Range coding is used to compress
the final bitstream like Huffman coding is used in Deflate.
@ -115,7 +115,6 @@ Q: I cannot find BCJ and BCJ2 filters. Don't they exist in liblzma?
A: BCJ filter is called "x86" in liblzma. BCJ2 is not included,
because it requires using more than one encoded output stream.
A streamable version of BCJ2-style filtering is planned.
Q: I need to use a script that runs "xz -9". On a system with 256 MiB
@ -148,25 +147,21 @@ A: See the documentation in XZ Embedded. In short, something like
xz --check=crc32 --powerpc --lzma2=preset=6e,dict=64KiB
Adjust dictionary size to get a good compromise between
Adjust the dictionary size to get a good compromise between
compression ratio and decompressor memory usage. Note that
in single-call decompression mode of XZ Embedded, a big
dictionary doesn't increase memory usage.
Q: Will xz support threaded compression?
Q: How is multi-threaded compression implemented in XZ Utils?
A: It is planned and has been taken into account when designing
the .xz file format. Eventually there will probably be three types
of threading, each method having its own advantages and disadvantages.
The simplest method is splitting the uncompressed data into blocks
A: The simplest method is splitting the uncompressed data into blocks
and compressing them in parallel independent from each other.
This is currently the only threading method supported in XZ Utils.
Since the blocks are compressed independently, they can also be
decompressed independently. Together with the index feature in .xz,
this allows using threads to create .xz files for random-access
reading. This also makes threaded decompression possible, although
it is not clear if threaded decompression will ever be implemented.
reading. This also makes threaded decompression possible.
The independent blocks method has a couple of disadvantages too. It
will compress worse than a single-block method. Often the difference
@ -174,31 +169,56 @@ A: It is planned and has been taken into account when designing
the memory usage of the compressor increases linearly when adding
threads.
Match finder parallelization is another threading method. It has
been in 7-Zip for ages. It doesn't affect compression ratio or
memory usage significantly. Among the three threading methods, only
this is useful when compressing small files (files that are not
significantly bigger than the dictionary). Unfortunately this method
scales only to about two CPU cores.
At least two other threading methods are possible but these haven't
been implemented in XZ Utils:
Match finder parallelization has been in 7-Zip for ages. It doesn't
affect compression ratio or memory usage significantly. Among the
three threading methods, only this is useful when compressing small
files (files that are not significantly bigger than the dictionary).
Unfortunately this method scales only to about two CPU cores.
The third method is pigz-style threading (I use that name, because
pigz <http://www.zlib.net/pigz/> uses that method). It doesn't
pigz <https://www.zlib.net/pigz/> uses that method). It doesn't
affect compression ratio significantly and scales to many cores.
The memory usage scales linearly when threads are added. It isn't
significant with pigz, because Deflate uses only 32 KiB dictionary,
The memory usage scales linearly when threads are added. This isn't
significant with pigz, because Deflate uses only a 32 KiB dictionary,
but with LZMA2 the memory usage will increase dramatically just like
with the independent blocks method. There is also a constant
with the independent-blocks method. There is also a constant
computational overhead, which may make pigz-method a bit dull on
dual-core compared to the parallel match finder method, but with more
cores the overhead is not a big deal anymore.
Combining the threading methods will be possible and also useful.
E.g. combining match finder parallelization with pigz-style threading
can cut the memory usage by 50 %.
For example, combining match finder parallelization with pigz-style
threading or independent-blocks-threading can cut the memory usage
by 50 %.
It is possible that the single-threaded method will be modified to
create files indentical to the pigz-style method. We'll see once
pigz-style threading has been implemented in liblzma.
Q: I told xz to use many threads but it is using only one or two
processor cores. What is wrong?
A: Since multi-threaded compression is done by splitting the data into
blocks that are compressed individually, if the input file is too
small for the block size, then many threads cannot be used. The
default block size increases when the compression level is
increased. For example, xz -6 uses 8 MiB LZMA2 dictionary and
24 MiB blocks, and xz -9 uses 64 MiB LZMA dictionary and 192 MiB
blocks. If the input file is 100 MiB, xz -6 can use five threads
of which one will finish quickly as it has only 4 MiB to compress.
However, for the same file, xz -9 can only use one thread.
One can adjust block size with --block-size=SIZE but making the
block size smaller than LZMA2 dictionary is waste of RAM: using
xz -9 with 6 MiB blocks isn't any better than using xz -6 with
6 MiB blocks. The default settings use a block size bigger than
the LZMA2 dictionary size because this was seen as a reasonable
compromise between RAM usage and compression ratio.
When decompressing, the ability to use threads depends on how the
file was created. If it was created in multi-threaded mode then
it can be decompressed in multi-threaded mode too if there are
multiple blocks in the file.
Q: How do I build a program that needs liblzmadec (lzmadec.h)?
@ -206,7 +226,7 @@ Q: How do I build a program that needs liblzmadec (lzmadec.h)?
A: liblzmadec is part of LZMA Utils. XZ Utils has liblzma, but no
liblzmadec. The code using liblzmadec should be ported to use
liblzma instead. If you cannot or don't want to do that, download
LZMA Utils from <http://tukaani.org/lzma/>.
LZMA Utils from <https://tukaani.org/lzma/>.
Q: The default build of liblzma is too big. How can I make it smaller?
@ -220,5 +240,5 @@ A: Give --enable-small to the configure script. Use also appropriate
If the result is still too big, take a look at XZ Embedded. It is
a separate project, which provides a limited but significantly
smaller XZ decoder implementation than XZ Utils. You can find it
at <http://tukaani.org/xz/embedded.html>.
at <https://xz.tukaani.org/xz-embedded/>.

View File

@ -4,12 +4,12 @@ History of LZMA Utils and XZ Utils
Tukaani distribution
In 2005, there was a small group working on Tukaani distribution, which
was a Slackware fork. One of the project goals was to fit the distro on
a single 700 MiB ISO-9660 image. Using LZMA instead of gzip helped a
lot. Roughly speaking, one could fit data that took 1000 MiB in gzipped
form into 700 MiB with LZMA. Naturally compression ratio varied across
packages, but this was what we got on average.
In 2005, there was a small group working on the Tukaani distribution,
which was a Slackware fork. One of the project's goals was to fit the
distro on a single 700 MiB ISO-9660 image. Using LZMA instead of gzip
helped a lot. Roughly speaking, one could fit data that took 1000 MiB
in gzipped form into 700 MiB with LZMA. Naturally, the compression
ratio varied across packages, but this was what we got on average.
Slackware packages have traditionally had .tgz as the filename suffix,
which is an abbreviation of .tar.gz. A logical naming for LZMA
@ -30,13 +30,13 @@ Tukaani distribution
First steps of LZMA Utils
The first version of LZMA Utils (4.22.0) included a shell script called
lzmash. It was wrapper that had gzip-like command line interface. It
lzmash. It was a wrapper that had a gzip-like command-line interface. It
used the LZMA_Alone tool from LZMA SDK to do all the real work. zgrep,
zdiff, and related scripts from gzip were adapted work with LZMA and
zdiff, and related scripts from gzip were adapted to work with LZMA and
were part of the first LZMA Utils release too.
LZMA Utils 4.22.0 included also lzmadec, which was a small (less than
10 KiB) decoder-only command line tool. It was written on top of the
10 KiB) decoder-only command-line tool. It was written on top of the
decoder-only C code found from the LZMA SDK. lzmadec was convenient in
situations where LZMA_Alone (a few hundred KiB) would be too big.
@ -48,33 +48,34 @@ Second generation
The lzmash script was an ugly and not very secure hack. The last
version of LZMA Utils to use lzmash was 4.27.1.
LZMA Utils 4.32.0beta1 introduced a new lzma command line tool written
LZMA Utils 4.32.0beta1 introduced a new lzma command-line tool written
by Ville Koskinen. It was written in C++, and used the encoder and
decoder from C++ LZMA SDK with little modifications. This tool replaced
both the lzmash script and the LZMA_Alone command line tool in LZMA
Utils.
decoder from C++ LZMA SDK with some little modifications. This tool
replaced both the lzmash script and the LZMA_Alone command-line tool
in LZMA Utils.
Introducing this new tool caused some temporary incompatibilities,
because LZMA_Alone executable was simply named lzma like the new
command line tool, but they had completely different command line
because the LZMA_Alone executable was simply named lzma like the new
command-line tool, but they had a completely different command-line
interface. The file format was still the same.
Lasse wrote liblzmadec, which was a small decoder-only library based
on the C code found from LZMA SDK. liblzmadec had API similar to zlib,
although there were some significant differences, which made it
on the C code found from LZMA SDK. liblzmadec had an API similar to
zlib, although there were some significant differences, which made it
non-trivial to use it in some applications designed for zlib and
libbzip2.
The lzmadec command line tool was converted to use liblzmadec.
The lzmadec command-line tool was converted to use liblzmadec.
Alexandre Sauvé helped converting build system to use GNU Autotools.
This made is easier to test for certain less portable features needed
by the new command line tool.
Alexandre Sauvé helped converting the build system to use GNU
Autotools. This made it easier to test for certain less portable
features needed by the new command-line tool.
Since the new command line tool never got completely finished (for
example, it didn't support LZMA_OPT environment variable), the intent
was to not call 4.32.x stable. Similarly, liblzmadec wasn't polished,
but appeared to work well enough, so some people started using it too.
Since the new command-line tool never got completely finished (for
example, it didn't support the LZMA_OPT environment variable), the
intent was to not call 4.32.x stable. Similarly, liblzmadec wasn't
polished, but appeared to work well enough, so some people started
using it too.
Because the development of the third generation of LZMA Utils was
delayed considerably (3-4 years), the 4.32.x branch had to be kept
@ -85,16 +86,16 @@ Second generation
File format problems
The file format used by LZMA_Alone was primitive. It was designed for
embedded systems in mind, and thus provided only minimal set of
features. The two biggest problems for non-embedded use were lack of
magic bytes and integrity check.
The file format used by LZMA_Alone was primitive. It was designed with
embedded systems in mind, and thus provided only a minimal set of
features. The two biggest problems for non-embedded use were the lack
of magic bytes and an integrity check.
Igor and Lasse started developing a new file format with some help
from Ville Koskinen. Also Mark Adler, Mikko Pouru, H. Peter Anvin,
and Lars Wirzenius helped with some minor things at some point of the
development. Designing the new format took quite a long time (actually,
too long time would be more appropriate expression). It was mostly
too long a time would be a more appropriate expression). It was mostly
because Lasse was quite slow at getting things done due to personal
reasons.
@ -102,7 +103,7 @@ File format problems
that was already used by the old file format. Switching to the new
format wouldn't have caused much trouble when the old format wasn't
used by many people. But since the development of the new format took
so long time, the old format got quite popular, and it was decided
such a long time, the old format got quite popular, and it was decided
that the new file format must use a different suffix.
It was decided to use .xz as the suffix of the new file format. The
@ -125,13 +126,13 @@ Transition to XZ Utils
The early versions of XZ Utils were called LZMA Utils. The first
releases were 4.42.0alphas. They dropped the rest of the C++ LZMA SDK.
The code was still directly based on LZMA SDK but ported to C and
converted from callback API to stateful API. Later, Igor Pavlov made
C version of the LZMA encoder too; these ports from C++ to C were
independent in LZMA SDK and LZMA Utils.
converted from a callback API to a stateful API. Later, Igor Pavlov
made a C version of the LZMA encoder too; these ports from C++ to C
were independent in LZMA SDK and LZMA Utils.
The core of the new LZMA Utils was liblzma, a compression library with
zlib-like API. liblzma supported both the old and new file format. The
gzip-like lzma command line tool was rewritten to use liblzma.
a zlib-like API. liblzma supported both the old and new file format.
The gzip-like lzma command-line tool was rewritten to use liblzma.
The new LZMA Utils code base was renamed to XZ Utils when the name
of the new file format had been decided. The liblzma compression
@ -139,7 +140,7 @@ Transition to XZ Utils
caused unnecessary breakage in applications already using the early
liblzma snapshots.
The xz command line tool can emulate the gzip-like lzma tool by
The xz command-line tool can emulate the gzip-like lzma tool by
creating appropriate symlinks (e.g. lzma -> xz). Thus, practically
all scripts using the lzma tool from LZMA Utils will work as is with
XZ Utils (and will keep using the old .lzma format). Still, the .lzma

View File

@ -40,7 +40,11 @@ The .lzma File Format
0.2. Changes
Last modified: 2009-05-01 11:15+0300
Last modified: 2024-01-16 18:00+0800
Compared to the previous version (2022-07-13 21:00+0300)
the section 2 was modified to change links from http to
https and to update XZ links.
1. File Format
@ -129,7 +133,10 @@ The .lzma File Format
Uncompressed Size is stored as unsigned 64-bit little endian
integer. A special value of 0xFFFF_FFFF_FFFF_FFFF indicates
that Uncompressed Size is unknown. End of Payload Marker (*)
is used if and only if Uncompressed Size is unknown.
is used if Uncompressed Size is unknown. End of Payload Marker
is allowed but rarely used if Uncompressed Size is known.
XZ Utils 5.2.5 and older don't support .lzma files that have
End of Payload Marker together with a known Uncompressed Size.
XZ Utils rejects files whose Uncompressed Size field specifies
a known size that is 256 GiB or more. This is to reject false
@ -150,17 +157,17 @@ The .lzma File Format
2. References
LZMA SDK - The original LZMA implementation
http://7-zip.org/sdk.html
https://7-zip.org/sdk.html
7-Zip
http://7-zip.org/
https://7-zip.org/
LZMA Utils - LZMA adapted to POSIX-like systems
http://tukaani.org/lzma/
https://tukaani.org/lzma/
XZ Utils - The next generation of LZMA Utils
http://tukaani.org/xz/
https://xz.tukaani.org/xz-utils/
The .xz file format - The successor of the the .lzma format
http://tukaani.org/xz/xz-file-format.txt
The .xz file format - The successor of the .lzma format
https://xz.tukaani.org/format/xz-file-format.txt

View File

@ -2,7 +2,7 @@
The .xz File Format
===================
Version 1.0.4 (2009-08-27)
Version 1.2.0 (2024-01-19)
0. Preface
@ -81,18 +81,26 @@ Version 1.0.4 (2009-08-27)
0.2. Getting the Latest Version
The latest official version of this document can be downloaded
from <http://tukaani.org/xz/xz-file-format.txt>.
from <https://xz.tukaani.org/format/xz-file-format.txt>.
Specific versions of this document have a filename
xz-file-format-X.Y.Z.txt where X.Y.Z is the version number.
For example, the version 1.0.0 of this document is available
at <http://tukaani.org/xz/xz-file-format-1.0.0.txt>.
at <https://xz.tukaani.org/format/xz-file-format-1.0.0.txt>.
0.3. Version History
Version Date Description
1.2.0 2024-01-19 Added RISC-V filter and updated URLs in
Sections 0.2 and 7. The URL of this
specification was changed.
1.1.0 2022-12-11 Added ARM64 filter and clarified 32-bit
ARM endianness in Section 5.3.2,
language improvements in Section 5.4
1.0.4 2009-08-27 Language improvements in Sections 1.2,
2.1.1.2, 3.1.1, 3.1.2, and 5.3.1
@ -915,9 +923,21 @@ Version 1.0.4 (2009-08-27)
0x04 1 byte x86 filter (BCJ)
0x05 4 bytes PowerPC (big endian) filter
0x06 16 bytes IA64 filter
0x07 4 bytes ARM (little endian) filter
0x08 2 bytes ARM Thumb (little endian) filter
0x07 4 bytes ARM filter [1]
0x08 2 bytes ARM Thumb filter [1]
0x09 4 bytes SPARC filter
0x0A 4 bytes ARM64 filter [2]
0x0B 2 bytes RISC-V filter
[1] These are for little endian instruction encoding.
This must not be confused with data endianness.
A processor configured for big endian data access
may still use little endian instruction encoding.
The filters don't care about the data endianness.
[2] 4096-byte alignment gives the best results
because the address in the ADRP instruction
is a multiple of 4096 bytes.
If the size of Filter Properties is four bytes, the Filter
Properties field contains the start offset used for address
@ -987,12 +1007,12 @@ Version 1.0.4 (2009-08-27)
5.4. Custom Filter IDs
If a developer wants to use custom Filter IDs, he has two
If a developer wants to use custom Filter IDs, there are two
choices. The first choice is to contact Lasse Collin and ask
him to allocate a range of IDs for the developer.
The second choice is to generate a 40-bit random integer,
which the developer can use as his personal Developer ID.
The second choice is to generate a 40-bit random integer
which the developer can use as a personal Developer ID.
To minimize the risk of collisions, Developer ID has to be
a randomly generated integer, not manually selected "hex word".
The following command, which works on many free operating
@ -1000,7 +1020,7 @@ Version 1.0.4 (2009-08-27)
dd if=/dev/urandom bs=5 count=1 | hexdump
The developer can then use his Developer ID to create unique
The developer can then use the Developer ID to create unique
(well, hopefully unique) Filter IDs.
Bits Mask Description
@ -1121,30 +1141,30 @@ Version 1.0.4 (2009-08-27)
7. References
LZMA SDK - The original LZMA implementation
http://7-zip.org/sdk.html
https://7-zip.org/sdk.html
LZMA Utils - LZMA adapted to POSIX-like systems
http://tukaani.org/lzma/
https://tukaani.org/lzma/
XZ Utils - The next generation of LZMA Utils
http://tukaani.org/xz/
https://xz.tukaani.org/xz-utils/
[RFC-1952]
GZIP file format specification version 4.3
http://www.ietf.org/rfc/rfc1952.txt
https://www.ietf.org/rfc/rfc1952.txt
- Notation of byte boxes in section "2.1. Overall conventions"
[RFC-2119]
Key words for use in RFCs to Indicate Requirement Levels
http://www.ietf.org/rfc/rfc2119.txt
https://www.ietf.org/rfc/rfc2119.txt
[GNU-tar]
GNU tar 1.21 manual
http://www.gnu.org/software/tar/manual/html_node/Blocking-Factor.html
GNU tar 1.35 manual
https://www.gnu.org/software/tar/manual/html_node/Blocking-Factor.html
- Node 9.4.2 "Blocking Factor", paragraph that begins
"gzip will complain about trailing garbage"
- Note that this URL points to the latest version of the
manual, and may some day not contain the note which is in
1.21. For the exact version of the manual, download GNU
tar 1.21: ftp://ftp.gnu.org/pub/gnu/tar/tar-1.21.tar.gz
1.35. For the exact version of the manual, download GNU
tar 1.35: ftp://ftp.gnu.org/pub/gnu/tar/tar-1.35.tar.gz

BIN
doc/xz-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

78
dos/INSTALL.txt Normal file
View File

@ -0,0 +1,78 @@
Building XZ Utils for DOS
=========================
Introduction
This document explains how to build XZ Utils for DOS using DJGPP.
The resulting binaries should run at least on various DOS versions
and under Windows 95/98/98SE/ME.
This is somewhat experimental and has got very little testing.
Note: Makefile and config.h are updated only now and then. This
means that if you checked out a development version, building for
DOS might not work without updating Makefile and config.h first.
Getting and Installing DJGPP
You may use <https://www.delorie.com/djgpp/zip-picker.html> to help
deciding what to download. If you are only interested in building
XZ Utils, the zip-picker may list files that you don't strictly
need. However, using the zip-picker can still be worth it to get a
nice short summary of installation instructions (they can be found
from readme.1st too).
For a more manual method, first select a mirror from
<https://www.delorie.com/djgpp/getting.html> and go the
subdirectory named "current". You need the following files:
unzip32.exe (if you don't already have a LFN-capable unzipper)
v2/djdev205.zip
v2gnu/bnu234b.zip
v2gnu/gcc920b.zip
v2gnu/mak43b.zip
v2misc/csdpmi7b.zip
If newer versions are available, probably you should try them first.
Note that versions older than djdev205.zip aren't supported. Also
note that you want csdpmi7b.zip even if you run under Windows or
DOSEMU because the XZ Utils Makefile will embed cwsdstub.exe to
the resulting xz.exe.
See the instructions in readme.1st found from djdev205.zip. Here's
a short summary, but you should still read readme.1st.
C:\> mkdir DJGPP
C:\> cd DJGPP
C:\DJGPP> c:\download\unzip32 c:\download\djdev205.zip
C:\DJGPP> c:\download\unzip32 c:\download\bnu234b.zip
C:\DJGPP> c:\download\unzip32 c:\download\gcc920b.zip
C:\DJGPP> c:\download\unzip32 c:\download\mak43b.zip
C:\DJGPP> c:\download\unzip32 c:\download\csdpmi7b.zip
C:\DJGPP> set PATH=C:\DJGPP\BIN;%PATH%
C:\DJGPP> set DJGPP=C:\DJGPP\DJGPP.ENV
You may want to add the last two lines into AUTOEXEC.BAT or have,
for example, DJGPP.BAT which you can run before using DJGPP.
Make sure you use completely upper case path in the DJGPP environment
variable. This is not required by DJGPP, but the XZ Utils Makefile is
a bit stupid and expects that everything in DJGPP environment variable
is uppercase.
Building
You need to have an environment that supports long filenames (LFN).
Once you have built XZ Utils, the resulting binaries can be run
without long filename support.
Run "make" in this directory (the directory containing this
INSTALL.txt). You should get xz.exe (and a bunch of temporary files).
Other tools are not built. Having e.g. xzdec.exe doesn't save much
space compared to xz.exe because the DJGPP runtime makes the .exe
quite big anyway.

View File

@ -1,12 +1,11 @@
# SPDX-License-Identifier: 0BSD
###############################################################################
#
# Makefile to build XZ Utils using DJGPP
#
# Author: Lasse Collin
#
# This file has been put into the public domain.
# You can do whatever you want with this file.
#
###############################################################################
# For debugging, set comment "#define NDEBUG 1" from config.h to enable
@ -16,11 +15,9 @@ CC = gcc
STRIP = strip
CPPFLAGS =
CFLAGS = -g -Wall -Wextra -Wfatal-errors -march=i386 -mtune=i686 -O2
LDFLAGS =
LDFLAGS = -lemu
# NOTE: -fgnu89-inline is needed on DJGPP 2.04 beta and GCC >= 4.3.0
# because time.h uses GNU-style "extern inline".
ALL_CFLAGS = -std=gnu99 -fgnu89-inline
ALL_CFLAGS = -std=gnu99
ALL_CPPFLAGS = \
-I. \
@ -64,6 +61,7 @@ SRCS_C = \
../src/liblzma/common/block_header_encoder.c \
../src/liblzma/common/block_util.c \
../src/liblzma/common/common.c \
../src/liblzma/common/file_info.c \
../src/liblzma/common/filter_common.c \
../src/liblzma/common/filter_decoder.c \
../src/liblzma/common/filter_encoder.c \
@ -74,11 +72,13 @@ SRCS_C = \
../src/liblzma/common/index_decoder.c \
../src/liblzma/common/index_encoder.c \
../src/liblzma/common/index_hash.c \
../src/liblzma/common/lzip_decoder.c \
../src/liblzma/common/stream_decoder.c \
../src/liblzma/common/stream_encoder.c \
../src/liblzma/common/stream_flags_common.c \
../src/liblzma/common/stream_flags_decoder.c \
../src/liblzma/common/stream_flags_encoder.c \
../src/liblzma/common/string_conversion.c \
../src/liblzma/common/vli_decoder.c \
../src/liblzma/common/vli_encoder.c \
../src/liblzma/common/vli_size.c \
@ -98,6 +98,7 @@ SRCS_C = \
../src/liblzma/lzma/lzma_encoder_presets.c \
../src/liblzma/rangecoder/price_table.c \
../src/liblzma/simple/arm.c \
../src/liblzma/simple/arm64.c \
../src/liblzma/simple/armthumb.c \
../src/liblzma/simple/ia64.c \
../src/liblzma/simple/powerpc.c \
@ -113,6 +114,7 @@ SRCS_C = \
../src/xz/list.c \
../src/xz/main.c \
../src/xz/message.c \
../src/xz/mytime.c \
../src/xz/options.c \
../src/xz/signals.c \
../src/xz/suffix.c \

View File

@ -1,88 +0,0 @@
XZ Utils on DOS
===============
Introduction
This document explains how to build XZ Utils for DOS using DJGPP.
The resulting binaries should run at least on various DOS versions
and under Windows 95/98/98SE/ME, although the Windows version of
XZ Utils is recommended under Windows 95 and later.
This is currently experimental and has got very little testing.
Note: Makefile and config.h are updated only now and then. This
means that especially if you checked out a development version,
building for DOS probably won't work without updating Makefile
and config.h first.
Getting and Installing DJGPP
You may use <http://www.delorie.com/djgpp/zip-picker.html> to help
deciding what to download, but as of writing (2010-10-09) that may
not be the most convenient way taking into account what components
are actually required to build XZ Utils. However, using the
zip-picker can still be worth doing to get nice short summary of
installation instructions (they can be found from readme.1st too).
For a more manual method, first select a mirror from
<http://www.delorie.com/djgpp/getting.html>. You need
the following files:
unzip32.exe (if you don't already have a LFN-capable unzipper)
beta/v2/djdev204.zip
v2gnu/bnu219b.zip
v2gnu/gcc444b.zip
v2gnu/mak3791b.zip
v2misc/csdpmi7b.zip
If newer versions are available, probably you should try them first.
Note that djdev203.zip is too old to build XZ Utils; you need at
least djdev204.zip. Also note that you want csdpmi7b.zip even if you
run under Windows or DOSEMU, because the XZ Utils Makefile will embed
cwsdstub.exe to the resulting binaries.
See the instructions in readme.1st found from djdev204.zip. Here's
a short summary, but you should still read readme.1st.
C:\> mkdir DJGPP
C:\> cd DJGPP
C:\DJGPP> c:\download\unzip32 c:\download\djdev204.zip
C:\DJGPP> c:\download\unzip32 c:\download\bnu219b.zip
C:\DJGPP> c:\download\unzip32 c:\download\gcc444b.zip
C:\DJGPP> c:\download\unzip32 c:\download\mak3791b.zip
C:\DJGPP> c:\download\unzip32 c:\download\csdpmi7b.zip
C:\DJGPP> set PATH=C:\DJGPP\BIN;%PATH%
C:\DJGPP> set DJGPP=C:\DJGPP\DJGPP.ENV
You may want to add the last two lines into AUTOEXEC.BAT or have,
for example, DJGPP.BAT which you can run before using DJGPP.
Make sure you use completely upper case path in the DJGPP environment
variable. This is not required by DJGPP, but the XZ Utils Makefile is
a bit stupid and expects that everything in DJGPP environment variable
is uppercase.
Building
You need to have an environment that supports long filenames (LFN).
Once you have built XZ Utils, the resulting binaries can be run
without long filename support.
Run "make" in this directory (the directory containing this README).
You should get xz.exe (and a bunch of temporary files). Other tools
are not built. Having e.g. xzdec.exe doesn't save much space compared
to xz.exe, because the DJGPP runtime makes the .exe quite big anyway.
Bugs
xz doesn't necessarily work in Dosbox. It should work in DOSEMU.
Pressing Ctrl-c or Ctrl-Break won't remove the incomplete target file
when running under Windows XP Command Prompt (something goes wrong
with SIGINT handling). It works correctly under Windows 95/98/98SE/ME.

123
dos/README.txt Normal file
View File

@ -0,0 +1,123 @@
XZ Utils on DOS
===============
DOS-specific filename handling
xz detects at runtime if long filename (LFN) support is
available and will use it by default. It can be disabled by
setting an environment variable:
set lfn=n
When xz is in LFN mode, it behaves pretty much the same as it
does on other operating systems. Examples:
xz foo.tar -> foo.tar.xz
xz -d foo.tar.xz -> foo.tar
xz -F lzma foo.tar -> foo.tar.lzma
xz -d foo.tar.lzma -> foo.tar
When LFN support isn't available or it is disabled with LFN=n
environment setting, xz works in short filename (SFN) mode. This
affects filename suffix handling when compressing.
When compressing to the .xz format in SFN mode:
- Files without an extension get .xz just like on LFN systems.
- *.tar files become *.txz (shorthand for *.tar.xz). *.txz
is recognized by xz on all supported operating systems.
(Try to avoid confusing this with gzipped .txt files.)
- Files with 1-3 character extension have their extension modified
so that the last character is a dash ("-"). If the extension
is already three characters, the last character is lost. The
resulting *.?- or *.??- filename is recognized in LFN mode, but
it isn't recognized by xz on other operating systems.
Examples:
xz foo -> foo.xz | xz -d foo.xz -> foo
xz foo.tar -> foo.txz | xz -d foo.txz -> foo.tar
xz foo.c -> foo.c- | xz -d foo.c- -> foo.c
xz read.me -> read.me- | xz -d read.me- -> read.me
xz foo.txt -> foo.tx- | xz -d foo.tx- -> foo.tx !
Note that in the last example above, the third character of the
filename extension is lost.
When compressing to the legacy .lzma format in SFN mode:
- *.tar files become *.tlz (shorthand for *.tar.lzma). *.tlz
is recognized by xz on all supported operating systems.
- Other files become *.lzm. The original filename extension
is lost. *.lzm is recognized also in LFN mode, but it is not
recognized by xz on other operating systems.
Examples:
xz -F lzma foo -> foo.lzm | xz -d foo.lzm -> foo
xz -F lzma foo.tar -> foo.tlz | xz -d foo.tlz -> foo.tar
xz -F lzma foo.c -> foo.lzm | xz -d foo.lzm -> foo !
xz -F lzma read.me -> read.lzm | xz -d read.lzm -> read !
xz -F lzma foo.txt -> foo.lzm | xz -d foo.lzm -> foo !
When compressing with a custom suffix (-S .SUF, --suffix=.SUF) to
any file format:
- If the suffix begins with a dot, the filename extension is
replaced with the new suffix. The original extension is lost.
- If the suffix doesn't begin with a dot and the filename has no
extension and the filename given on the command line doesn't
have a dot at the end, the custom suffix is appended just like
on LFN systems.
- If the suffix doesn't begin with a dot and the filename has
an extension (or an extension-less filename is given with a dot
at the end), the last 1-3 characters of the filename extension
may get overwritten to fit the given custom suffix.
Examples:
xz -S x foo -> foox | xz -dS x foox -> foo
xz -S x foo. -> foo.x | xz -dS x foo.x -> foo
xz -S .x foo -> foo.x | xz -dS .x foo.x -> foo
xz -S .x foo. -> foo.x | xz -dS .x foo.x -> foo
xz -S x.y foo -> foox.y | xz -dS x.y foox.y -> foo
xz -S .a foo.c -> foo.a | xz -dS .a foo.a -> foo !
xz -S a foo.c -> foo.ca | xz -dS a foo.ca -> foo.c
xz -S ab foo.c -> foo.cab | xz -dS ab foo.cab -> foo.c
xz -S ab read.me -> read.mab | xz -dS ab read.mab -> read.m !
xz -S ab foo.txt -> foo.tab | xz -dS ab foo.tab -> foo.t !
xz -S abc foo.txt -> foo.abc | xz -dS abc foo.abc -> foo !
When decompressing, the suffix handling in SFN mode is the same as
in LFN mode. The DOS-specific filenames *.lzm, *.?-, and *.??- are
recognized also in LFN mode.
xz handles certain uncommon situations safely:
- If the generated output filename refers to the same file as
the input file, xz detects this and refuses to compress or
decompress the input file even if --force is used. This can
happen when giving an overlong filename in SFN mode. E.g.
"xz -S x foo.texinfo" would try to write to foo.tex which on
SFN system is the same file as foo.texinfo.
- If the generated output filename is a special file like "con"
or "prn", xz detects this and refuses to compress or decompress
the input file even if --force is used.
Bugs
xz doesn't necessarily work in Dosbox. It should work in DOSEMU.
Pressing Ctrl-c or Ctrl-Break won't remove the incomplete target file
when running under Windows XP Command Prompt (something goes wrong
with SIGINT handling). It works correctly under Windows 95/98/98SE/ME.

View File

@ -1,3 +1,5 @@
/* SPDX-License-Identifier: 0BSD */
/* How many MiB of RAM to assume if the real amount cannot be determined. */
#define ASSUME_RAM 32
@ -10,9 +12,15 @@
/* Define to 1 if sha256 integrity check is enabled. */
#define HAVE_CHECK_SHA256 1
/* Define to 1 if any of HAVE_DECODER_foo have been defined. */
#define HAVE_DECODERS 1
/* Define to 1 if arm decoder is enabled. */
#define HAVE_DECODER_ARM 1
/* Define to 1 if arm64 decoder is enabled. */
#define HAVE_DECODER_ARM64 1
/* Define to 1 if armthumb decoder is enabled. */
#define HAVE_DECODER_ARMTHUMB 1
@ -37,9 +45,15 @@
/* Define to 1 if x86 decoder is enabled. */
#define HAVE_DECODER_X86 1
/* Define to 1 if any of HAVE_ENCODER_foo have been defined. */
#define HAVE_ENCODERS 1
/* Define to 1 if arm encoder is enabled. */
#define HAVE_ENCODER_ARM 1
/* Define to 1 if arm64 encoder is enabled. */
#define HAVE_ENCODER_ARM64 1
/* Define to 1 if armthumb encoder is enabled. */
#define HAVE_ENCODER_ARMTHUMB 1
@ -70,6 +84,9 @@
/* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define to 1 if .lz (lzip) decompression support is enabled. */
#define HAVE_LZIP_DECODER 1
/* Define to 1 to enable bt2 match finder. */
#define HAVE_MF_BT2 1
@ -100,29 +117,37 @@
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define to 1 if you have the `utimes' function. */
/* Define to 1 if you have the 'utimes' function. */
#define HAVE_UTIMES 1
/* Define to 1 or 0, depending whether the compiler supports simple visibility
declarations. */
#define HAVE_VISIBILITY 0
/* Define to 1 if the system has the type `_Bool'. */
/* Define to 1 if the system has the type '_Bool'. */
#define HAVE__BOOL 1
/* Define to 1 if the GNU C extension __builtin_assume_aligned is supported.
*/
#define HAVE___BUILTIN_ASSUME_ALIGNED 1
/* Define to 1 if the GNU C extensions __builtin_bswap16/32/64 are supported.
*/
#define HAVE___BUILTIN_BSWAPXX 1
/* Define to 1 to disable debugging code. */
#define NDEBUG 1
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "lasse.collin@tukaani.org"
#define PACKAGE_BUGREPORT "xz@tukaani.org"
/* Define to the full name of this package. */
#define PACKAGE_NAME "XZ Utils"
/* Define to the home page for this package. */
#define PACKAGE_URL "http://tukaani.org/xz/"
#define PACKAGE_URL "https://xz.tukaani.org/xz-utils/"
/* The size of `size_t', as computed by sizeof. */
/* The size of 'size_t', as computed by sizeof. */
#define SIZEOF_SIZE_T 4
/* Define to 1 if the system supports fast unaligned access to 16-bit and

2687
doxygen/Doxyfile Normal file

File diff suppressed because it is too large Load Diff

13
doxygen/footer.html Normal file
View File

@ -0,0 +1,13 @@
<hr class="footer"/>
<p style="text-align: right;padding-right: 12px;">
XZ logo &copy; 2023 by Jia Tan is licensed under
<a href="COPYING.CC-BY-SA-4.0"
rel="license"
style="display:inline-block;">
CC BY-SA 4.0
</a>
</p>
</body>
</html>

109
doxygen/update-doxygen Executable file
View File

@ -0,0 +1,109 @@
#!/bin/sh
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# Updates the Doxygen generated documentation files in the source tree.
# If the doxygen command is not installed, it will exit with an error.
# This script can generate Doxygen documentation for all source files or for
# just liblzma API header files.
#
# It is recommended to use this script to update the Doxygen-generated HTML
# files since this will include the package version in the output and,
# in case of liblzma API docs, strip JavaScript files from the output.
#
#############################################################################
#
# Authors: Jia Tan
# Lasse Collin
#
#############################################################################
set -e
if type doxygen > /dev/null 2>&1; then
:
else
echo "doxygen/update-doxygen: 'doxygen' command not found." >&2
echo "doxygen/update-doxygen: Skipping Doxygen docs generation." >&2
exit 1
fi
if test ! -f Doxyfile; then
cd `dirname "$0"` || exit 1
if test ! -f Doxyfile; then
echo "doxygen/update-doxygen: Cannot find Doxyfile" >&2
exit 1
fi
fi
# Get the package version so that it can be included in the generated docs.
PACKAGE_VERSION=`cd .. && sh build-aux/version.sh` || exit 1
# If no arguments are specified, default to generating liblzma API header
# documentation only.
case $1 in
'' | api)
# Remove old documentation before re-generating the new.
rm -rf ../doc/api
# Generate the HTML documentation by preparing the Doxyfile
# in stdin and piping the result to the doxygen command.
# With Doxygen, the last assignment of a value to a tag will
# override any earlier assignment. So, we can use this
# feature to override the tags that need to change between
# "api" and "internal" modes.
(
cat Doxyfile
echo "PROJECT_NUMBER = $PACKAGE_VERSION"
) | doxygen -
# As of Doxygen 1.8.0 - 1.9.6 and the Doxyfile options we use,
# the output is good without any JavaScript. Unfortunately
# Doxygen doesn't have an option to disable JavaScript usage
# completely so we strip it away with the hack below.
#
# Omitting the JavaScript code avoids some license hassle
# as jquery.js is fairly big, it contains more than jQuery
# itself, and doesn't include the actual license text (it
# only refers to the MIT license by name).
echo "Stripping JavaScript from Doxygen output..."
for F in ../doc/api/*.html
do
sed 's/<script [^>]*><\/script>//g
s/onclick="[^"]*"//g' \
"$F" > ../doc/api/tmp
mv -f ../doc/api/tmp "$F"
done
rm -f ../doc/api/*.js
;;
internal)
# The docs from internal aren't for distribution so
# the JavaScript files aren't an issue here.
rm -rf ../doc/internal
(
cat Doxyfile
echo "PROJECT_NUMBER = $PACKAGE_VERSION"
echo 'PROJECT_NAME = "XZ Utils"'
echo 'STRIP_FROM_PATH = ../src'
echo 'INPUT = ../src'
echo 'HTML_OUTPUT = internal'
echo 'EXTRACT_PRIVATE = YES'
echo 'EXTRACT_STATIC = YES'
echo 'EXTRACT_LOCAL_CLASSES = YES'
echo 'SEARCHENGINE = YES'
) | doxygen -
;;
*)
echo "doxygen/update-doxygen: Error: mode argument '$1'" \
"is not supported." >&2
echo "doxygen/update-doxygen: Supported modes:" >&2
echo "doxygen/update-doxygen: - 'api' (default):" \
"liblzma API docs into doc/api" >&2
echo "doxygen/update-doxygen: - 'internal':"\
"internal docs into doc/internal" >&2
exit 1
;;
esac

View File

@ -1,5 +1,6 @@
#!/bin/bash
#
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# 7z2lzma.bash is very primitive .7z to .lzma converter. The input file must
@ -17,9 +18,6 @@
#
# Author: Lasse Collin <lasse.collin@tukaani.org>
#
# This file has been put into the public domain.
# You can do whatever you want with this file.
#
#############################################################################
# You can use 7z or 7za, both will work.

View File

@ -1,3 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
scanlzma, scan for lzma compressed data in stdin and echo it to stdout.
Copyright (C) 2006 Timo Lindfors
@ -37,6 +39,10 @@
/* 5 8 Uncompressed size (little endian). -1 means unknown size */
/* 13 Compressed data */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define BUFSIZE 4096
int find_lzma_header(unsigned char *buf) {
@ -48,7 +54,7 @@ int find_lzma_header(unsigned char *buf) {
}
int main(int argc, char *argv[]) {
char buf[BUFSIZE];
unsigned char buf[BUFSIZE];
int ret, i, numlzma, blocks=0;
if (argc != 2) {

View File

@ -1,3 +1,5 @@
## SPDX-License-Identifier: GPL-2.0-or-later
##
## Copyright (C) 2004-2007 Free Software Foundation, Inc.
##
@ -21,7 +23,17 @@ libgnu_a_SOURCES =
libgnu_a_DEPENDENCIES = $(LIBOBJS)
libgnu_a_LIBADD = $(LIBOBJS)
EXTRA_DIST = getopt.in.h getopt.c getopt1.c getopt_int.h
EXTRA_DIST = \
getopt.in.h \
getopt.c \
getopt1.c \
getopt_int.h \
getopt-cdefs.h \
getopt-core.h \
getopt-ext.h \
getopt-pfx-core.h \
getopt-pfx-ext.h
BUILT_SOURCES = $(GETOPT_H)
MOSTLYCLEANFILES = getopt.h getopt.h-t

72
lib/getopt-cdefs.h Normal file
View File

@ -0,0 +1,72 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/* getopt-on-non-glibc compatibility macros.
Copyright (C) 1989-2023 Free Software Foundation, Inc.
This file is part of gnulib.
Unlike most of the getopt implementation, it is NOT shared
with the GNU C Library.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GETOPT_CDEFS_H
#define _GETOPT_CDEFS_H 1
/* This header should not be used directly; include getopt.h or
unistd.h instead. It does not have a protective #error, because
the guard macro for getopt.h in gnulib is not fixed. */
/* getopt-core.h and getopt-ext.h are shared with GNU libc, and expect
a number of the internal macros supplied to GNU libc's headers by
sys/cdefs.h. Provide fallback definitions for all of them. */
#ifdef HAVE_SYS_CDEFS_H
# include <sys/cdefs.h>
#endif
#ifndef __BEGIN_DECLS
# ifdef __cplusplus
# define __BEGIN_DECLS extern "C" {
# else
# define __BEGIN_DECLS /* nothing */
# endif
#endif
#ifndef __END_DECLS
# ifdef __cplusplus
# define __END_DECLS }
# else
# define __END_DECLS /* nothing */
# endif
#endif
#ifndef __GNUC_PREREQ
# if defined __GNUC__ && defined __GNUC_VERSION__
# define __GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
# else
# define __GNUC_PREREQ(maj, min) 0
# endif
#endif
#ifndef __THROW
# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
# if __cplusplus >= 201103L
# define __THROW noexcept (true)
# else
# define __THROW throw ()
# endif
# else
# define __THROW
# endif
#endif
#endif /* _GETOPT_CDEFS_H */

98
lib/getopt-core.h Normal file
View File

@ -0,0 +1,98 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/* Declarations for getopt (basic, portable features only).
Copyright (C) 1989-2023 Free Software Foundation, Inc.
This file is part of the GNU C Library and is also part of gnulib.
Patches to this file should be submitted to both projects.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef _GETOPT_CORE_H
#define _GETOPT_CORE_H 1
/* This header should not be used directly; include getopt.h or
unistd.h instead. Unlike most bits headers, it does not have
a protective #error, because the guard macro for getopt.h in
gnulib is not fixed. */
__BEGIN_DECLS
/* For communication from 'getopt' to the caller.
When 'getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when 'ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to 'getopt'.
On entry to 'getopt', zero means this is the first call; initialize.
When 'getopt' returns -1, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, 'optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
extern int optind;
/* Callers store zero here to inhibit the error message 'getopt' prints
for unrecognized options. */
extern int opterr;
/* Set to an option character which was unrecognized. */
extern int optopt;
/* Get definitions and prototypes for functions to process the
arguments in ARGV (ARGC of them, minus the program name) for
options given in OPTS.
Return the option character from OPTS just read. Return -1 when
there are no more options. For unrecognized options, or options
missing arguments, 'optopt' is set to the option letter, and '?' is
returned.
The OPTS string is a list of characters which are recognized option
letters, optionally followed by colons, specifying that that letter
takes an argument, to be placed in 'optarg'.
If a letter in OPTS is followed by two colons, its argument is
optional. This behavior is specific to the GNU 'getopt'.
The argument '--' causes premature termination of argument
scanning, explicitly telling 'getopt' that there are no more
options.
If OPTS begins with '-', then non-option arguments are treated as
arguments to the option '\1'. This behavior is specific to the GNU
'getopt'. If OPTS begins with '+', or POSIXLY_CORRECT is set in
the environment, then do not permute arguments.
For standards compliance, the 'argv' argument has the type
char *const *, but this is inaccurate; if argument permutation is
enabled, the argv array (not the strings it points to) must be
writable. */
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
__THROW _GL_ARG_NONNULL ((2, 3));
__END_DECLS
#endif /* _GETOPT_CORE_H */

79
lib/getopt-ext.h Normal file
View File

@ -0,0 +1,79 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/* Declarations for getopt (GNU extensions).
Copyright (C) 1989-2023 Free Software Foundation, Inc.
This file is part of the GNU C Library and is also part of gnulib.
Patches to this file should be submitted to both projects.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef _GETOPT_EXT_H
#define _GETOPT_EXT_H 1
/* This header should not be used directly; include getopt.h instead.
Unlike most bits headers, it does not have a protective #error,
because the guard macro for getopt.h in gnulib is not fixed. */
__BEGIN_DECLS
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
of 'struct option' terminated by an element containing a name which is
zero.
The field 'has_arg' is:
no_argument (or 0) if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
optional_argument (or 2) if the option takes an optional argument.
If the field 'flag' is not NULL, it points to a variable that is set
to the value given in the field 'val' when the option is found, but
left unchanged if the option is not found.
To have a long-named option do something other than set an 'int' to
a compiled-in constant, such as set a value from 'optarg', set the
option's 'flag' field to zero and its 'val' field to a nonzero
value (the equivalent single-letter option character, if there is
one). For long options that have a zero 'flag' field, 'getopt'
returns the contents of the 'val' field. */
struct option
{
const char *name;
/* has_arg can't be an enum because some compilers complain about
type mismatches in all the code that assumes it is an int. */
int has_arg;
int *flag;
int val;
};
/* Names for the values of the 'has_arg' field of 'struct option'. */
#define no_argument 0
#define required_argument 1
#define optional_argument 2
extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind)
__THROW _GL_ARG_NONNULL ((2, 3));
extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind)
__THROW _GL_ARG_NONNULL ((2, 3));
__END_DECLS
#endif /* _GETOPT_EXT_H */

68
lib/getopt-pfx-core.h Normal file
View File

@ -0,0 +1,68 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/* getopt (basic, portable features) gnulib wrapper header.
Copyright (C) 1989-2023 Free Software Foundation, Inc.
This file is part of gnulib.
Unlike most of the getopt implementation, it is NOT shared
with the GNU C Library.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GETOPT_PFX_CORE_H
#define _GETOPT_PFX_CORE_H 1
/* This header should not be used directly; include getopt.h or
unistd.h instead. It does not have a protective #error, because
the guard macro for getopt.h in gnulib is not fixed. */
/* Standalone applications should #define __GETOPT_PREFIX to an
identifier that prefixes the external functions and variables
defined in getopt-core.h and getopt-ext.h. Systematically
rename identifiers so that they do not collide with the system
functions and variables. Renaming avoids problems with some
compilers and linkers. */
#ifdef __GETOPT_PREFIX
# ifndef __GETOPT_ID
# define __GETOPT_CONCAT(x, y) x ## y
# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
# endif
# undef getopt
# undef optarg
# undef opterr
# undef optind
# undef optopt
# define getopt __GETOPT_ID (getopt)
# define optarg __GETOPT_ID (optarg)
# define opterr __GETOPT_ID (opterr)
# define optind __GETOPT_ID (optind)
# define optopt __GETOPT_ID (optopt)
/* Work around a problem on macOS, which declares getopt with a
trailing __DARWIN_ALIAS(getopt) that would expand to something like
__asm("_" "rpl_getopt" "$UNIX2003") were it not for the following
hack to suppress the macOS declaration <https://bugs.gnu.org/40205>. */
# ifdef __APPLE__
# define _GETOPT
# endif
/* The system's getopt.h may have already included getopt-core.h to
declare the unprefixed identifiers. Undef _GETOPT_CORE_H so that
getopt-core.h declares them with prefixes. */
# undef _GETOPT_CORE_H
#endif
#include <getopt-core.h>
#endif /* _GETOPT_PFX_CORE_H */

72
lib/getopt-pfx-ext.h Normal file
View File

@ -0,0 +1,72 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/* getopt (GNU extensions) gnulib wrapper header.
Copyright (C) 1989-2023 Free Software Foundation, Inc.
This file is part of gnulib.
Unlike most of the getopt implementation, it is NOT shared
with the GNU C Library.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GETOPT_PFX_EXT_H
#define _GETOPT_PFX_EXT_H 1
/* This header should not be used directly; include getopt.h instead.
It does not have a protective #error, because the guard macro for
getopt.h in gnulib is not fixed. */
/* Standalone applications should #define __GETOPT_PREFIX to an
identifier that prefixes the external functions and variables
defined in getopt-core.h and getopt-ext.h. Systematically
rename identifiers so that they do not collide with the system
functions and variables. Renaming avoids problems with some
compilers and linkers. */
#ifdef __GETOPT_PREFIX
# ifndef __GETOPT_ID
# define __GETOPT_CONCAT(x, y) x ## y
# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
# endif
# undef getopt_long
# undef getopt_long_only
# undef option
# undef _getopt_internal
# define getopt_long __GETOPT_ID (getopt_long)
# define getopt_long_only __GETOPT_ID (getopt_long_only)
# define option __GETOPT_ID (option)
# define _getopt_internal __GETOPT_ID (getopt_internal)
/* The system's getopt.h may have already included getopt-ext.h to
declare the unprefixed identifiers. Undef _GETOPT_EXT_H so that
getopt-ext.h declares them with prefixes. */
# undef _GETOPT_EXT_H
#endif
/* Standalone applications get correct prototypes for getopt_long and
getopt_long_only; they declare "char **argv". For backward
compatibility with old applications, if __GETOPT_PREFIX is not
defined, we supply GNU-libc-compatible, but incorrect, prototypes
using "char *const *argv". (GNU libc is stuck with the incorrect
prototypes, as they are baked into older versions of LSB.) */
#ifndef __getopt_argv_const
# if defined __GETOPT_PREFIX
# define __getopt_argv_const /* empty */
# else
# define __getopt_argv_const const
# endif
#endif
#include <getopt-ext.h>
#endif /* _GETOPT_PFX_EXT_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +1,28 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/* Declarations for getopt.
Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005,2006,2007
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Copyright (C) 1989-2023 Free Software Foundation, Inc.
This file is part of gnulib.
Unlike most of the getopt implementation, it is NOT shared
with the GNU C Library, which supplies a different version of
this file.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1, or (at your option)
any later version.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GETOPT_H
#ifndef __need_getopt
# define _GETOPT_H 1
#endif
#define _GETOPT_H 1
/* Standalone applications should #define __GETOPT_PREFIX to an
identifier that prefixes the external functions and variables
@ -31,196 +32,29 @@
identifiers so that they do not collide with the system functions
and variables. Renaming avoids problems with some compilers and
linkers. */
#if defined __GETOPT_PREFIX && !defined __need_getopt
#if defined __GETOPT_PREFIX
# include <stdlib.h>
# include <stdio.h>
# include <unistd.h>
# undef __need_getopt
# undef getopt
# undef getopt_long
# undef getopt_long_only
# undef optarg
# undef opterr
# undef optind
# undef optopt
# define __GETOPT_CONCAT(x, y) x ## y
# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
# define getopt __GETOPT_ID (getopt)
# define getopt_long __GETOPT_ID (getopt_long)
# define getopt_long_only __GETOPT_ID (getopt_long_only)
# define optarg __GETOPT_ID (optarg)
# define opterr __GETOPT_ID (opterr)
# define optind __GETOPT_ID (optind)
# define optopt __GETOPT_ID (optopt)
# ifndef _MSC_VER
# include <unistd.h>
# endif
#endif
/* Standalone applications get correct prototypes for getopt_long and
getopt_long_only; they declare "char **argv". libc uses prototypes
with "char *const *argv" that are incorrect because getopt_long and
getopt_long_only can permute argv; this is required for backward
compatibility (e.g., for LSB 2.0.1).
This used to be `#if defined __GETOPT_PREFIX && !defined __need_getopt',
but it caused redefinition warnings if both unistd.h and getopt.h were
included, since unistd.h includes getopt.h having previously defined
__need_getopt.
The only place where __getopt_argv_const is used is in definitions
of getopt_long and getopt_long_only below, but these are visible
only if __need_getopt is not defined, so it is quite safe to rewrite
the conditional as follows:
*/
#if !defined __need_getopt
# if defined __GETOPT_PREFIX
# define __getopt_argv_const /* empty */
/* From Gnulib's lib/arg-nonnull.h: */
/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
that the values passed as arguments n, ..., m must be non-NULL pointers.
n = 1 stands for the first argument, n = 2 for the second argument etc. */
#ifndef _GL_ARG_NONNULL
# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__
# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
# else
# define __getopt_argv_const const
# define _GL_ARG_NONNULL(params)
# endif
#endif
/* If __GNU_LIBRARY__ is not already defined, either we are being used
standalone, or this is the first header included in the source file.
If we are being used with glibc, we need to include <features.h>, but
that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
not defined, include <ctype.h>, which will pull in <features.h> for us
if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
doesn't flood the namespace with stuff the way some other headers do.) */
#if !defined __GNU_LIBRARY__
# include <ctype.h>
#endif
#include <getopt-cdefs.h>
#include <getopt-pfx-core.h>
#include <getopt-pfx-ext.h>
#ifndef __THROW
# ifndef __GNUC_PREREQ
# define __GNUC_PREREQ(maj, min) (0)
# endif
# if defined __cplusplus && __GNUC_PREREQ (2,8)
# define __THROW throw ()
# else
# define __THROW
# endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns -1, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
extern int optind;
/* Callers store zero here to inhibit the error message `getopt' prints
for unrecognized options. */
extern int opterr;
/* Set to an option character which was unrecognized. */
extern int optopt;
#ifndef __need_getopt
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
of `struct option' terminated by an element containing a name which is
zero.
The field `has_arg' is:
no_argument (or 0) if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
left unchanged if the option is not found.
To have a long-named option do something other than set an `int' to
a compiled-in constant, such as set a value from `optarg', set the
option's `flag' field to zero and its `val' field to a nonzero
value (the equivalent single-letter option character, if there is
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
struct option
{
const char *name;
/* has_arg can't be an enum because some compilers complain about
type mismatches in all the code that assumes it is an int. */
int has_arg;
int *flag;
int val;
};
/* Names for the values of the `has_arg' field of `struct option'. */
# define no_argument 0
# define required_argument 1
# define optional_argument 2
#endif /* need getopt */
/* Get definitions and prototypes for functions to process the
arguments in ARGV (ARGC of them, minus the program name) for
options given in OPTS.
Return the option character from OPTS just read. Return -1 when
there are no more options. For unrecognized options, or options
missing arguments, `optopt' is set to the option letter, and '?' is
returned.
The OPTS string is a list of characters which are recognized option
letters, optionally followed by colons, specifying that that letter
takes an argument, to be placed in `optarg'.
If a letter in OPTS is followed by two colons, its argument is
optional. This behavior is specific to the GNU `getopt'.
The argument `--' causes premature termination of argument
scanning, explicitly telling `getopt' that there are no more
options.
If OPTS begins with `-', then non-option arguments are treated as
arguments to the option '\1'. This behavior is specific to the GNU
`getopt'. If OPTS begins with `+', or POSIXLY_CORRECT is set in
the environment, then do not permute arguments. */
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
__THROW;
#ifndef __need_getopt
extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind)
__THROW;
extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind)
__THROW;
#endif
#ifdef __cplusplus
}
#endif
/* Make sure we later can get all the definitions and declarations. */
#undef __need_getopt
#endif /* getopt.h */
#endif /* _GETOPT_H */

View File

@ -1,42 +1,33 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/* getopt_long and getopt_long_only entry points for GNU getopt.
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004,2006
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of the GNU C Library and is also part of gnulib.
Patches to this file should be submitted to both projects.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1, or (at your option)
any later version.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#ifdef _LIBC
# include <getopt.h>
#else
# include <config.h>
# include "getopt.h"
#ifndef _LIBC
# ifdef HAVE_CONFIG_H
# include <config.h>
# endif
#endif
#include "getopt.h"
#include "getopt_int.h"
#include <stdio.h>
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
#include <stdlib.h>
#endif
#ifndef NULL
#define NULL 0
#endif
int
getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
const struct option *long_options, int *opt_index)
@ -51,7 +42,7 @@ _getopt_long_r (int argc, char **argv, const char *options,
struct _getopt_data *d)
{
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
0, 0, d);
0, d, 0);
}
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
@ -74,13 +65,14 @@ _getopt_long_only_r (int argc, char **argv, const char *options,
struct _getopt_data *d)
{
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
1, 0, d);
1, d, 0);
}
#ifdef TEST
#include <stdio.h>
#include <stdlib.h>
int
main (int argc, char **argv)
@ -92,7 +84,7 @@ main (int argc, char **argv)
{
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] =
static const struct option long_options[] =
{
{"add", 1, 0, 0},
{"append", 0, 0, 0},
@ -142,11 +134,11 @@ main (int argc, char **argv)
break;
case 'c':
printf ("option c with value `%s'\n", optarg);
printf ("option c with value '%s'\n", optarg);
break;
case 'd':
printf ("option d with value `%s'\n", optarg);
printf ("option d with value '%s'\n", optarg);
break;
case '?':

View File

@ -1,34 +1,64 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/* Internal declarations for getopt.
Copyright (C) 1989-1994,1996-1999,2001,2003,2004
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Copyright (C) 1989-2023 Free Software Foundation, Inc.
This file is part of the GNU C Library and is also part of gnulib.
Patches to this file should be submitted to both projects.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef _GETOPT_INT_H
#define _GETOPT_INT_H 1
#include <getopt.h>
extern int _getopt_internal (int ___argc, char **___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind,
const struct option *__longopts, int *__longind,
int __long_only, int __posixly_correct);
/* Reentrant versions which can handle parsing multiple argument
vectors at the same time. */
/* Describe how to deal with options that follow non-option ARGV-elements.
REQUIRE_ORDER means don't recognize them as options; stop option
processing when the first non-option is seen. This is what POSIX
specifies should happen.
PERMUTE means permute the contents of ARGV as we scan, so that
eventually all the non-options are at the end. This allows options
to be given in any order, even with programs that were not written
to expect this.
RETURN_IN_ORDER is an option available to programs that were
written to expect options and other ARGV-elements in any order
and that care about the ordering of the two. We describe each
non-option ARGV-element as if it were the argument of an option
with character code 1.
The special argument '--' forces an end of option-scanning regardless
of the value of 'ordering'. In the case of RETURN_IN_ORDER, only
'--' can cause 'getopt' to return -1 with 'optind' != ARGC. */
enum __ord
{
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
};
/* Data type for reentrant functions. */
struct _getopt_data
{
@ -53,58 +83,17 @@ struct _getopt_data
by advancing to the next ARGV-element. */
char *__nextchar;
/* Describe how to deal with options that follow non-option ARGV-elements.
If the caller did not specify anything,
the default is REQUIRE_ORDER if the environment variable
POSIXLY_CORRECT is defined, PERMUTE otherwise.
REQUIRE_ORDER means don't recognize them as options;
stop option processing when the first non-option is seen.
This is what Unix does.
This mode of operation is selected by either setting the environment
variable POSIXLY_CORRECT, or using `+' as the first character
of the list of option characters, or by calling getopt.
PERMUTE is the default. We permute the contents of ARGV as we
scan, so that eventually all the non-options are at the end.
This allows options to be given in any order, even with programs
that were not written to expect this.
RETURN_IN_ORDER is an option available to programs that were
written to expect options and other ARGV-elements in any order
and that care about the ordering of the two. We describe each
non-option ARGV-element as if it were the argument of an option
with character code 1. Using `-' as the first character of the
list of option characters selects this mode of operation.
The special argument `--' forces an end of option-scanning regardless
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
`--' can cause `getopt' to return -1 with `optind' != ARGC. */
enum
{
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
} __ordering;
/* If the POSIXLY_CORRECT environment variable is set
or getopt was called. */
int __posixly_correct;
/* See __ord above. */
enum __ord __ordering;
/* Handle permutation of arguments. */
/* Describe the part of ARGV that contains non-options that have
been skipped. `first_nonopt' is the index in ARGV of the first
of them; `last_nonopt' is the index after the last of them. */
been skipped. 'first_nonopt' is the index in ARGV of the first
of them; 'last_nonopt' is the index after the last of them. */
int __first_nonopt;
int __last_nonopt;
#if defined _LIBC && defined USE_NONOPTION_FLAGS
int __nonoption_flags_max_len;
int __nonoption_flags_len;
# endif
};
/* The initializer is necessary to set OPTIND and OPTERR to their
@ -114,8 +103,8 @@ struct _getopt_data
extern int _getopt_internal_r (int ___argc, char **___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind,
int __long_only, int __posixly_correct,
struct _getopt_data *__data);
int __long_only, struct _getopt_data *__data,
int __posixly_correct);
extern int _getopt_long_r (int ___argc, char **___argv,
const char *__shortopts,

7
m4/.gitignore vendored
View File

@ -1,11 +1,16 @@
build-to-host.m4
codeset.m4
extern-inline.m4
fcntl-o.m4
gettext.m4
glibc2.m4
glibc21.m4
host-cpu-c-abi.m4
iconv.m4
intdiv0.m4
intl.m4
intldir.m4
intlmacosx.m4
intmax.m4
inttypes-pri.m4
inttypes_h.m4
@ -27,9 +32,9 @@ printf-posix.m4
progtest.m4
size_max.m4
stdint_h.m4
threadlib.m4
uintmax_t.m4
ulonglong.m4
visibility.m4
wchar_t.m4
wint_t.m4
xsize.m4

View File

@ -1,279 +0,0 @@
##### http://autoconf-archive.cryp.to/acx_pthread.html
#
# SYNOPSIS
#
# ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro figures out how to build C programs using POSIX threads.
# It sets the PTHREAD_LIBS output variable to the threads library and
# linker flags, and the PTHREAD_CFLAGS output variable to any special
# C compiler flags that are needed. (The user can also force certain
# compiler flags/libs to be tested by setting these environment
# variables.)
#
# Also sets PTHREAD_CC to any special C compiler that is needed for
# multi-threaded programs (defaults to the value of CC otherwise).
# (This is necessary on AIX to use the special cc_r compiler alias.)
#
# NOTE: You are assumed to not only compile your program with these
# flags, but also link it with them as well. e.g. you should link
# with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
# $LIBS
#
# If you are only building threads programs, you may wish to use
# these variables in your default LIBS, CFLAGS, and CC:
#
# LIBS="$PTHREAD_LIBS $LIBS"
# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# CC="$PTHREAD_CC"
#
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
# constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
#
# ACTION-IF-FOUND is a list of shell commands to run if a threads
# library is found, and ACTION-IF-NOT-FOUND is a list of commands to
# run it if it is not found. If ACTION-IF-FOUND is not specified, the
# default action will define HAVE_PTHREAD.
#
# Please let the authors know if this macro fails on any platform, or
# if you have any other suggestions or comments. This macro was based
# on work by SGJ on autoconf scripts for FFTW (http://www.fftw.org/)
# (with help from M. Frigo), as well as ac_pthread and hb_pthread
# macros posted by Alejandro Forero Cuervo to the autoconf macro
# repository. We are also grateful for the helpful feedback of
# numerous users.
#
# LAST MODIFICATION
#
# 2007-07-29
#
# COPYLEFT
#
# Copyright (c) 2007 Steven G. Johnson <stevenj@alum.mit.edu>
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright
# owner gives unlimited permission to copy, distribute and modify the
# configure scripts that are the output of Autoconf when processing
# the Macro. You need not follow the terms of the GNU General Public
# License when using or distributing such scripts, even though
# portions of the text of the Macro appear in them. The GNU General
# Public License (GPL) does govern all other use of the material that
# constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the
# Autoconf Macro released by the Autoconf Macro Archive. When you
# make and distribute a modified version of the Autoconf Macro, you
# may extend this special exception to the GPL to apply to your
# modified version as well.
AC_DEFUN([ACX_PTHREAD], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_LANG_SAVE
AC_LANG_C
acx_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h
# requires special compiler flags (e.g. on True64 or Sequent).
# It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS,
# etcetera environment variables, and if threads linking works using
# them:
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
AC_MSG_RESULT($acx_pthread_ok)
if test x"$acx_pthread_ok" = xno; then
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
fi
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
fi
# We must check for the threads library under a number of different
# names; the ordering is very important because some systems
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
# libraries is broken (non-POSIX).
# Create a list of thread flags to try. Items starting with a "-" are
# C compiler flags, and other items are library names, except for "none"
# which indicates that we try without any flags at all, and "pthread-config"
# which is a program returning the flags for the Pth emulation library.
acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
# pthreads: AIX (must check this before -lpthread)
# none: in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
# -pthreads: Solaris/gcc
# -mthreads: Mingw32/gcc, Lynx/gcc
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads too;
# also defines -D_REENTRANT)
# ... -mt is also the pthreads flag for HP/aCC
# pthread: Linux, etcetera
# --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library)
case "${host_cpu}-${host_os}" in
*solaris*)
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (We need to link with -pthreads/-mt/
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
# a function called by this macro, so we could check for that, but
# who knows whether they'll stub that too in a future libc.) So,
# we'll just look for -pthreads and -lpthread first:
acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
;;
esac
if test x"$acx_pthread_ok" = xno; then
for flag in $acx_pthread_flags; do
case $flag in
none)
AC_MSG_CHECKING([whether pthreads work without any flags])
;;
-*)
AC_MSG_CHECKING([whether pthreads work with $flag])
PTHREAD_CFLAGS="$flag"
;;
pthread-config)
AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
if test x"$acx_pthread_config" = xno; then continue; fi
PTHREAD_CFLAGS="`pthread-config --cflags`"
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
;;
*)
AC_MSG_CHECKING([for the pthreads library -l$flag])
PTHREAD_LIBS="-l$flag"
;;
esac
save_LIBS="$LIBS"
save_CFLAGS="$CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# Check for various functions. We must include pthread.h,
# since some functions may be macros. (On the Sequent, we
# need a special flag -Kthread to make this header compile.)
# We check for pthread_join because it is in -lpthread on IRIX
# while pthread_create is in libc. We check for pthread_attr_init
# due to DEC craziness with -lpthreads. We check for
# pthread_cleanup_push because it is one of the few pthread
# functions on Solaris that doesn't have a non-functional libc stub.
# We try pthread_create on general principles.
AC_TRY_LINK([#include <pthread.h>],
[pthread_t th; pthread_join(th, 0);
pthread_attr_init(0); pthread_cleanup_push(0, 0);
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
[acx_pthread_ok=yes])
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
AC_MSG_RESULT($acx_pthread_ok)
if test "x$acx_pthread_ok" = xyes; then
break;
fi
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
done
fi
# Various other checks:
if test "x$acx_pthread_ok" = xyes; then
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
AC_MSG_CHECKING([for joinable pthread attribute])
attr_name=unknown
for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
[attr_name=$attr; break])
done
AC_MSG_RESULT($attr_name)
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
[Define to necessary symbol if this constant
uses a non-standard name on your system.])
fi
AC_MSG_CHECKING([if more special flags are required for pthreads])
flag=no
case "${host_cpu}-${host_os}" in
*-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
*solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
esac
AC_MSG_RESULT(${flag})
if test "x$flag" != xno; then
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
fi
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
# More AIX lossage: must compile with xlc_r or cc_r
if test x"$GCC" != xyes; then
AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
else
PTHREAD_CC=$CC
fi
else
PTHREAD_CC="$CC"
fi
AC_SUBST(PTHREAD_LIBS)
AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(PTHREAD_CC)
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test x"$acx_pthread_ok" = xyes; then
ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
:
else
acx_pthread_ok=no
$2
fi
AC_LANG_RESTORE
])dnl ACX_PTHREAD

524
m4/ax_pthread.m4 Normal file
View File

@ -0,0 +1,524 @@
dnl SPDX-License-Identifier: GPL-3.0-or-later WITH Autoconf-exception-macro
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_pthread.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro figures out how to build C programs using POSIX threads. It
# sets the PTHREAD_LIBS output variable to the threads library and linker
# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
# flags that are needed. (The user can also force certain compiler
# flags/libs to be tested by setting these environment variables.)
#
# Also sets PTHREAD_CC and PTHREAD_CXX to any special C compiler that is
# needed for multi-threaded programs (defaults to the value of CC
# respectively CXX otherwise). (This is necessary on e.g. AIX to use the
# special cc_r/CC_r compiler alias.)
#
# NOTE: You are assumed to not only compile your program with these flags,
# but also to link with them as well. For example, you might link with
# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
# $PTHREAD_CXX $CXXFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
#
# If you are only building threaded programs, you may wish to use these
# variables in your default LIBS, CFLAGS, and CC:
#
# LIBS="$PTHREAD_LIBS $LIBS"
# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
# CC="$PTHREAD_CC"
# CXX="$PTHREAD_CXX"
#
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to
# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
#
# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
# PTHREAD_CFLAGS.
#
# ACTION-IF-FOUND is a list of shell commands to run if a threads library
# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
# is not found. If ACTION-IF-FOUND is not specified, the default action
# will define HAVE_PTHREAD.
#
# Please let the authors know if this macro fails on any platform, or if
# you have any other suggestions or comments. This macro was based on work
# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
# Alejandro Forero Cuervo to the autoconf macro repository. We are also
# grateful for the helpful feedback of numerous users.
#
# Updated for Autoconf 2.68 by Daniel Richard G.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
# Copyright (c) 2019 Marc Stevens <marc.stevens@cwi.nl>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 31
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([AX_PTHREAD], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_PROG_SED])
AC_LANG_PUSH([C])
ax_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h
# requires special compiler flags (e.g. on Tru64 or Sequent).
# It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS,
# etcetera environment variables, and if threads linking works using
# them:
if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
ax_pthread_save_CC="$CC"
ax_pthread_save_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS"
AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
AS_IF([test "x$PTHREAD_CXX" != "x"], [CXX="$PTHREAD_CXX"])
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS])
AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes])
AC_MSG_RESULT([$ax_pthread_ok])
if test "x$ax_pthread_ok" = "xno"; then
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
fi
CC="$ax_pthread_save_CC"
CFLAGS="$ax_pthread_save_CFLAGS"
LIBS="$ax_pthread_save_LIBS"
fi
# We must check for the threads library under a number of different
# names; the ordering is very important because some systems
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
# libraries is broken (non-POSIX).
# Create a list of thread flags to try. Items with a "," contain both
# C compiler flags (before ",") and linker flags (after ","). Other items
# starting with a "-" are C compiler flags, and remaining items are
# library names, except for "none" which indicates that we try without
# any flags at all, and "pthread-config" which is a program returning
# the flags for the Pth emulation library.
ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
# pthreads: AIX (must check this before -lpthread)
# none: in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64
# (Note: HP C rejects this with "bad form for `-t' option")
# -pthreads: Solaris/gcc (Note: HP C also rejects)
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads and
# -D_REENTRANT too), HP C (must be checked before -lpthread, which
# is present but should not be used directly; and before -mthreads,
# because the compiler interprets this as "-mt" + "-hreads")
# -mthreads: Mingw32/gcc, Lynx/gcc
# pthread: Linux, etcetera
# --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library)
case $host_os in
freebsd*)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
ax_pthread_flags="-kthread lthread $ax_pthread_flags"
;;
hpux*)
# From the cc(1) man page: "[-mt] Sets various -D flags to enable
# multi-threading and also sets -lpthread."
ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags"
;;
openedition*)
# IBM z/OS requires a feature-test macro to be defined in order to
# enable POSIX threads at all, so give the user a hint if this is
# not set. (We don't define these ourselves, as they can affect
# other portions of the system API in unpredictable ways.)
AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING],
[
# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)
AX_PTHREAD_ZOS_MISSING
# endif
],
[AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])])
;;
solaris*)
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (N.B.: The stubs are missing
# pthread_cleanup_push, or rather a function called by this macro,
# so we could check for that, but who knows whether they'll stub
# that too in a future libc.) So we'll check first for the
# standard Solaris way of linking pthreads (-mt -lpthread).
ax_pthread_flags="-mt,-lpthread pthread $ax_pthread_flags"
;;
esac
# Are we compiling with Clang?
AC_CACHE_CHECK([whether $CC is Clang],
[ax_cv_PTHREAD_CLANG],
[ax_cv_PTHREAD_CLANG=no
# Note that Autoconf sets GCC=yes for Clang as well as GCC
if test "x$GCC" = "xyes"; then
AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG],
[/* Note: Clang 2.7 lacks __clang_[a-z]+__ */
# if defined(__clang__) && defined(__llvm__)
AX_PTHREAD_CC_IS_CLANG
# endif
],
[ax_cv_PTHREAD_CLANG=yes])
fi
])
ax_pthread_clang="$ax_cv_PTHREAD_CLANG"
# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)
# Note that for GCC and Clang -pthread generally implies -lpthread,
# except when -nostdlib is passed.
# This is problematic using libtool to build C++ shared libraries with pthread:
# [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460
# [2] https://bugzilla.redhat.com/show_bug.cgi?id=661333
# [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468555
# To solve this, first try -pthread together with -lpthread for GCC
AS_IF([test "x$GCC" = "xyes"],
[ax_pthread_flags="-pthread,-lpthread -pthread -pthreads $ax_pthread_flags"])
# Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first
AS_IF([test "x$ax_pthread_clang" = "xyes"],
[ax_pthread_flags="-pthread,-lpthread -pthread"])
# The presence of a feature test macro requesting re-entrant function
# definitions is, on some systems, a strong hint that pthreads support is
# correctly enabled
case $host_os in
darwin* | hpux* | linux* | osf* | solaris*)
ax_pthread_check_macro="_REENTRANT"
;;
aix*)
ax_pthread_check_macro="_THREAD_SAFE"
;;
*)
ax_pthread_check_macro="--"
;;
esac
AS_IF([test "x$ax_pthread_check_macro" = "x--"],
[ax_pthread_check_cond=0],
[ax_pthread_check_cond="!defined($ax_pthread_check_macro)"])
if test "x$ax_pthread_ok" = "xno"; then
for ax_pthread_try_flag in $ax_pthread_flags; do
case $ax_pthread_try_flag in
none)
AC_MSG_CHECKING([whether pthreads work without any flags])
;;
*,*)
PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"`
PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"`
AC_MSG_CHECKING([whether pthreads work with "$PTHREAD_CFLAGS" and "$PTHREAD_LIBS"])
;;
-*)
AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag])
PTHREAD_CFLAGS="$ax_pthread_try_flag"
;;
pthread-config)
AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
AS_IF([test "x$ax_pthread_config" = "xno"], [continue])
PTHREAD_CFLAGS="`pthread-config --cflags`"
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
;;
*)
AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag])
PTHREAD_LIBS="-l$ax_pthread_try_flag"
;;
esac
ax_pthread_save_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
# Check for various functions. We must include pthread.h,
# since some functions may be macros. (On the Sequent, we
# need a special flag -Kthread to make this header compile.)
# We check for pthread_join because it is in -lpthread on IRIX
# while pthread_create is in libc. We check for pthread_attr_init
# due to DEC craziness with -lpthreads. We check for
# pthread_cleanup_push because it is one of the few pthread
# functions on Solaris that doesn't have a non-functional libc stub.
# We try pthread_create on general principles.
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
# if $ax_pthread_check_cond
# error "$ax_pthread_check_macro must be defined"
# endif
static void *some_global = NULL;
static void routine(void *a)
{
/* To avoid any unused-parameter or
unused-but-set-parameter warning. */
some_global = a;
}
static void *start_routine(void *a) { return a; }],
[pthread_t th; pthread_attr_t attr;
pthread_create(&th, 0, start_routine, 0);
pthread_join(th, 0);
pthread_attr_init(&attr);
pthread_cleanup_push(routine, 0);
pthread_cleanup_pop(0) /* ; */])],
[ax_pthread_ok=yes],
[])
CFLAGS="$ax_pthread_save_CFLAGS"
LIBS="$ax_pthread_save_LIBS"
AC_MSG_RESULT([$ax_pthread_ok])
AS_IF([test "x$ax_pthread_ok" = "xyes"], [break])
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
done
fi
# Clang needs special handling, because older versions handle the -pthread
# option in a rather... idiosyncratic way
if test "x$ax_pthread_clang" = "xyes"; then
# Clang takes -pthread; it has never supported any other flag
# (Note 1: This will need to be revisited if a system that Clang
# supports has POSIX threads in a separate library. This tends not
# to be the way of modern systems, but it's conceivable.)
# (Note 2: On some systems, notably Darwin, -pthread is not needed
# to get POSIX threads support; the API is always present and
# active. We could reasonably leave PTHREAD_CFLAGS empty. But
# -pthread does define _REENTRANT, and while the Darwin headers
# ignore this macro, third-party headers might not.)
# However, older versions of Clang make a point of warning the user
# that, in an invocation where only linking and no compilation is
# taking place, the -pthread option has no effect ("argument unused
# during compilation"). They expect -pthread to be passed in only
# when source code is being compiled.
#
# Problem is, this is at odds with the way Automake and most other
# C build frameworks function, which is that the same flags used in
# compilation (CFLAGS) are also used in linking. Many systems
# supported by AX_PTHREAD require exactly this for POSIX threads
# support, and in fact it is often not straightforward to specify a
# flag that is used only in the compilation phase and not in
# linking. Such a scenario is extremely rare in practice.
#
# Even though use of the -pthread flag in linking would only print
# a warning, this can be a nuisance for well-run software projects
# that build with -Werror. So if the active version of Clang has
# this misfeature, we search for an option to squash it.
AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread],
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG],
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown
# Create an alternate version of $ac_link that compiles and
# links in two steps (.c -> .o, .o -> exe) instead of one
# (.c -> exe), because the warning occurs only in the second
# step
ax_pthread_save_ac_link="$ac_link"
ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g'
ax_pthread_link_step=`AS_ECHO(["$ac_link"]) | sed "$ax_pthread_sed"`
ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)"
ax_pthread_save_CFLAGS="$CFLAGS"
for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do
AS_IF([test "x$ax_pthread_try" = "xunknown"], [break])
CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS"
ac_link="$ax_pthread_save_ac_link"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
[ac_link="$ax_pthread_2step_ac_link"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
[break])
])
done
ac_link="$ax_pthread_save_ac_link"
CFLAGS="$ax_pthread_save_CFLAGS"
AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no])
ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
])
case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in
no | unknown) ;;
*) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;;
esac
fi # $ax_pthread_clang = yes
# Various other checks:
if test "x$ax_pthread_ok" = "xyes"; then
ax_pthread_save_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
AC_CACHE_CHECK([for joinable pthread attribute],
[ax_cv_PTHREAD_JOINABLE_ATTR],
[ax_cv_PTHREAD_JOINABLE_ATTR=unknown
for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
[int attr = $ax_pthread_attr; return attr /* ; */])],
[ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break],
[])
done
])
AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \
test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \
test "x$ax_pthread_joinable_attr_defined" != "xyes"],
[AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE],
[$ax_cv_PTHREAD_JOINABLE_ATTR],
[Define to necessary symbol if this constant
uses a non-standard name on your system.])
ax_pthread_joinable_attr_defined=yes
])
AC_CACHE_CHECK([whether more special flags are required for pthreads],
[ax_cv_PTHREAD_SPECIAL_FLAGS],
[ax_cv_PTHREAD_SPECIAL_FLAGS=no
case $host_os in
solaris*)
ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS"
;;
esac
])
AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \
test "x$ax_pthread_special_flags_added" != "xyes"],
[PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"
ax_pthread_special_flags_added=yes])
AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
[ax_cv_PTHREAD_PRIO_INHERIT],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
[[int i = PTHREAD_PRIO_INHERIT;
return i;]])],
[ax_cv_PTHREAD_PRIO_INHERIT=yes],
[ax_cv_PTHREAD_PRIO_INHERIT=no])
])
AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \
test "x$ax_pthread_prio_inherit_defined" != "xyes"],
[AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])
ax_pthread_prio_inherit_defined=yes
])
CFLAGS="$ax_pthread_save_CFLAGS"
LIBS="$ax_pthread_save_LIBS"
# More AIX lossage: compile with *_r variant
if test "x$GCC" != "xyes"; then
case $host_os in
aix*)
AS_CASE(["x/$CC"],
[x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
[#handle absolute path differently from PATH based program lookup
AS_CASE(["x$CC"],
[x/*],
[
AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])
AS_IF([test "x${CXX}" != "x"], [AS_IF([AS_EXECUTABLE_P([${CXX}_r])],[PTHREAD_CXX="${CXX}_r"])])
],
[
AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])
AS_IF([test "x${CXX}" != "x"], [AC_CHECK_PROGS([PTHREAD_CXX],[${CXX}_r],[$CXX])])
]
)
])
;;
esac
fi
fi
test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX"
AC_SUBST([PTHREAD_LIBS])
AC_SUBST([PTHREAD_CFLAGS])
AC_SUBST([PTHREAD_CC])
AC_SUBST([PTHREAD_CXX])
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test "x$ax_pthread_ok" = "xyes"; then
ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
:
else
ax_pthread_ok=no
$2
fi
AC_LANG_POP
])dnl AX_PTHREAD

View File

@ -1,71 +1,72 @@
# getopt.m4 serial 14 (modified version)
dnl Copyright (C) 2002-2006, 2008 Free Software Foundation, Inc.
dnl SPDX-License-Identifier: FSFULLR
# getopt.m4 serial 49 (modified version)
dnl Copyright (C) 2002-2006, 2008-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
# The getopt module assume you want GNU getopt, with getopt_long etc,
# rather than vanilla POSIX getopt. This means your code should
# always include <getopt.h> for the getopt prototypes.
# This version has been modified to reduce complexity since we only need
# GNU getopt_long and do not care about replacing getopt.
AC_DEFUN([gl_GETOPT_SUBSTITUTE],
# Check for a POSIX compliant getopt function with GNU extensions (such as
# options with optional arguments) and the functions getopt_long,
# getopt_long_only.
AC_DEFUN([gl_FUNC_GETOPT_GNU],
[
AC_LIBOBJ([getopt])
AC_LIBOBJ([getopt1])
gl_GETOPT_SUBSTITUTE_HEADER
])
AC_REQUIRE([gl_GETOPT_CHECK_HEADERS])
AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
[
GETOPT_H=getopt.h
AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
[Define to rpl_ if the getopt replacement functions and variables
should be used.])
AC_SUBST([GETOPT_H])
if test -n "$gl_replace_getopt"; then
gl_GETOPT_SUBSTITUTE
fi
])
AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
[
if test -z "$GETOPT_H"; then
AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h])
gl_replace_getopt=
if test -z "$gl_replace_getopt"; then
AC_CHECK_HEADERS([getopt.h], [], [gl_replace_getopt=yes])
fi
if test -z "$GETOPT_H"; then
AC_CHECK_FUNCS([getopt_long], [], [GETOPT_H=getopt.h])
if test -z "$gl_replace_getopt"; then
AC_CHECK_FUNCS([getopt_long], [], [gl_replace_getopt=yes])
fi
dnl BSD getopt_long uses a way to reset option processing, that is different
dnl from GNU and Solaris (which copied the GNU behavior). We support both
dnl GNU and BSD style resetting of getopt_long(), so there's no need to use
dnl GNU getopt_long() on BSD due to different resetting style.
dnl
dnl With getopt_long(), some BSD versions have a bug in handling optional
dnl arguments. This bug appears only if the environment variable
dnl POSIXLY_CORRECT has been set, so it shouldn't be too bad in most
dnl cases; probably most don't have that variable set. But if we actually
dnl hit this bug, it is a real problem due to our heavy use of optional
dnl arguments.
dnl
dnl According to CVS logs, the bug was introduced in OpenBSD in 2003-09-22
dnl and copied to FreeBSD in 2004-02-24. It was fixed in both in 2006-09-22,
dnl so the affected versions shouldn't be popular anymore anyway. NetBSD
dnl never had this bug. TODO: What about Darwin and others?
if test -z "$GETOPT_H"; then
if test -z "$gl_replace_getopt"; then
AC_CHECK_DECL([optreset],
[AC_DEFINE([HAVE_OPTRESET], 1,
[Define to 1 if getopt.h declares extern int optreset.])],
[], [#include <getopt.h>])
fi
dnl Solaris 10 getopt doesn't handle `+' as a leading character in an
dnl option string (as of 2005-05-05). We don't use that feature, so this
dnl POSIX 2008 does not specify leading '+' behavior, but see
dnl http://austingroupbugs.net/view.php?id=191 for a recommendation on
dnl the next version of POSIX. We don't use that feature, so this
dnl is not a problem for us. Thus, the respective test was removed here.
dnl Checks for getopt handling '-' as a leading character in an option
dnl string were removed, since we also don't use that feature.
])
AC_DEFUN([gl_GETOPT_IFELSE],
AC_DEFUN([gl_GETOPT_SUBSTITUTE],
[
AC_REQUIRE([gl_GETOPT_CHECK_HEADERS])
AS_IF([test -n "$GETOPT_H"], [$1], [$2])
AC_LIBOBJ([getopt])
AC_LIBOBJ([getopt1])
AC_CHECK_HEADERS_ONCE([sys/cdefs.h])
AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
[Define to rpl_ if the getopt replacement functions and variables
should be used.])
GETOPT_H=getopt.h
AC_SUBST([GETOPT_H])
])
AC_DEFUN([gl_GETOPT], [gl_GETOPT_IFELSE([gl_GETOPT_SUBSTITUTE])])
AC_DEFUN([gl_GETOPT], [gl_FUNC_GETOPT_GNU])

View File

@ -1,3 +1,5 @@
dnl SPDX-License-Identifier: FSFULLR
# Find a POSIX-conforming shell.
# Copyright (C) 2007-2008 Free Software Foundation, Inc.

View File

@ -1,3 +1,6 @@
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# SYNOPSIS
#
@ -7,13 +10,11 @@
#
# Common checks for tuklib.
#
# COPYING
#############################################################################
#
# Author: Lasse Collin
#
# This file has been put into the public domain.
# You can do whatever you want with this file.
# Author: Lasse Collin
#
#############################################################################
AC_DEFUN_ONCE([TUKLIB_COMMON], [
AC_REQUIRE([AC_CANONICAL_HOST])

View File

@ -1,3 +1,6 @@
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# SYNOPSIS
#
@ -9,17 +12,19 @@
# This information is used by tuklib_cpucores.c.
#
# Supported methods:
# - GetSystemInfo(): Windows (including Cygwin)
# - sched_getaffinity(): glibc (GNU/Linux, GNU/kFreeBSD)
# - cpuset_getaffinity(): FreeBSD
# - sysctl(): BSDs, OS/2
# - sysconf(): GNU/Linux, Solaris, Tru64, IRIX, AIX, Cygwin
# - sysconf(): GNU/Linux, Solaris, Tru64, IRIX, AIX, QNX, Cygwin (but
# GetSystemInfo() is used on Cygwin)
# - pstat_getdynamic(): HP-UX
#
# COPYING
#############################################################################
#
# Author: Lasse Collin
#
# This file has been put into the public domain.
# You can do whatever you want with this file.
# Author: Lasse Collin
#
#############################################################################
AC_DEFUN_ONCE([TUKLIB_CPUCORES], [
AC_REQUIRE([TUKLIB_COMMON])
@ -30,11 +35,67 @@ AC_CHECK_HEADERS([sys/param.h])
AC_CACHE_CHECK([how to detect the number of available CPU cores],
[tuklib_cv_cpucores_method], [
# Look for sysctl() solution first, because on OS/2, both sysconf()
# and sysctl() pass the tests in this file, but only sysctl()
# actually works.
# Maybe checking $host_os would be enough but this matches what
# tuklib_cpucores.c does.
#
# NOTE: IRIX has a compiler that doesn't error out with #error, so use
# a non-compilable text instead of #error to generate an error.
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <sys/types.h>
#if defined(_WIN32) || defined(__CYGWIN__)
int main(void) { return 0; }
#else
compile error
#endif
]])], [tuklib_cv_cpucores_method=special], [
# glibc-based systems (GNU/Linux and GNU/kFreeBSD) have sched_getaffinity().
# The CPU_COUNT() macro was added in glibc 2.9 so we try to link the
# test program instead of merely compiling it. glibc 2.9 is old enough that
# if someone uses the code on older glibc, the fallback to sysconf() should
# be good enough.
AC_LINK_IFELSE([AC_LANG_SOURCE([[
#include <sched.h>
int
main(void)
{
cpu_set_t cpu_mask;
sched_getaffinity(0, sizeof(cpu_mask), &cpu_mask);
return CPU_COUNT(&cpu_mask);
}
]])], [tuklib_cv_cpucores_method=sched_getaffinity], [
# FreeBSD has both cpuset and sysctl. Look for cpuset first because
# it's a better approach.
#
# This test would match on GNU/kFreeBSD too but it would require
# -lfreebsd-glue when linking and thus in the current form this would
# fail on GNU/kFreeBSD. The above test for sched_getaffinity() matches
# on GNU/kFreeBSD so the test below should never run on that OS.
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <sys/param.h>
#include <sys/cpuset.h>
int
main(void)
{
cpuset_t set;
cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1,
sizeof(set), &set);
return 0;
}
]])], [tuklib_cv_cpucores_method=cpuset], [
# On OS/2, both sysconf() and sysctl() pass the tests in this file,
# but only sysctl() works. On QNX it's the opposite: only sysconf() works
# (although it assumes that _POSIX_SOURCE, _XOPEN_SOURCE, and _POSIX_C_SOURCE
# are undefined or alternatively _QNX_SOURCE is defined).
#
# We test sysctl() first and intentionally break the sysctl() test on QNX
# so that sysctl() is never used on QNX.
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#ifdef __QNX__
compile error
#endif
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
@ -42,7 +103,12 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
int
main(void)
{
#ifdef HW_NCPUONLINE
/* This is preferred on OpenBSD, see tuklib_cpucores.c. */
int name[2] = { CTL_HW, HW_NCPUONLINE };
#else
int name[2] = { CTL_HW, HW_NCPU };
#endif
int cpus;
size_t cpus_size = sizeof(cpus);
sysctl(name, 2, &cpus, &cpus_size, NULL, 0);
@ -82,9 +148,19 @@ main(void)
]])], [tuklib_cv_cpucores_method=pstat_getdynamic], [
tuklib_cv_cpucores_method=unknown
])])])])
])])])])])])])
case $tuklib_cv_cpucores_method in
sched_getaffinity)
AC_DEFINE([TUKLIB_CPUCORES_SCHED_GETAFFINITY], [1],
[Define to 1 if the number of available CPU cores
can be detected with sched_getaffinity()])
;;
cpuset)
AC_DEFINE([TUKLIB_CPUCORES_CPUSET], [1],
[Define to 1 if the number of available CPU cores
can be detected with cpuset(2).])
;;
sysctl)
AC_DEFINE([TUKLIB_CPUCORES_SYSCTL], [1],
[Define to 1 if the number of available CPU cores

View File

@ -1,3 +1,6 @@
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# SYNOPSIS
#
@ -7,28 +10,41 @@
#
# Checks for tuklib_integer.h:
# - Endianness
# - Does operating system provide byte swapping macros
# - Does the hardware support fast unaligned access to 16-bit
# and 32-bit integers
# - Does the compiler or the operating system provide byte swapping macros
# - Does the hardware support fast unaligned access to 16-bit, 32-bit,
# and 64-bit integers
#
# COPYING
#############################################################################
#
# Author: Lasse Collin
#
# This file has been put into the public domain.
# You can do whatever you want with this file.
# Author: Lasse Collin
#
#############################################################################
AC_DEFUN_ONCE([TUKLIB_INTEGER], [
AC_REQUIRE([TUKLIB_COMMON])
AC_REQUIRE([AC_C_BIGENDIAN])
AC_CHECK_HEADERS([byteswap.h sys/endian.h sys/byteorder.h], [break])
# Even if we have byteswap.h, we may lack the specific macros/functions.
if test x$ac_cv_header_byteswap_h = xyes ; then
m4_foreach([FUNC], [bswap_16,bswap_32,bswap_64], [
AC_MSG_CHECKING([if FUNC is available])
AC_LINK_IFELSE([AC_LANG_SOURCE([
AC_MSG_CHECKING([if __builtin_bswap16/32/64 are supported])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
[[__builtin_bswap16(1);
__builtin_bswap32(1);
__builtin_bswap64(1);]])],
[
AC_DEFINE([HAVE___BUILTIN_BSWAPXX], [1],
[Define to 1 if the GNU C extensions
__builtin_bswap16/32/64 are supported.])
AC_MSG_RESULT([yes])
], [
AC_MSG_RESULT([no])
# Look for other byteswapping methods.
AC_CHECK_HEADERS([byteswap.h sys/endian.h sys/byteorder.h], [break])
# Even if we have byteswap.h we may lack the specific macros/functions.
if test x$ac_cv_header_byteswap_h = xyes ; then
m4_foreach([FUNC], [bswap_16,bswap_32,bswap_64], [
AC_MSG_CHECKING([if FUNC is available])
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <byteswap.h>
int
main(void)
@ -36,28 +52,61 @@ main(void)
FUNC[](42);
return 0;
}
])], [
AC_DEFINE(HAVE_[]m4_toupper(FUNC), [1],
])], [
AC_DEFINE(HAVE_[]m4_toupper(FUNC), [1],
[Define to 1 if] FUNC [is available.])
AC_MSG_RESULT([yes])
], [AC_MSG_RESULT([no])])
AC_MSG_RESULT([yes])
], [AC_MSG_RESULT([no])])
])dnl
fi
])dnl
fi
])
AC_MSG_CHECKING([if unaligned memory access should be used])
AC_ARG_ENABLE([unaligned-access], AC_HELP_STRING([--enable-unaligned-access],
AC_ARG_ENABLE([unaligned-access], AS_HELP_STRING([--enable-unaligned-access],
[Enable if the system supports *fast* unaligned memory access
with 16-bit and 32-bit integers. By default, this is enabled
only on x86, x86_64, and big endian PowerPC.]),
with 16-bit, 32-bit, and 64-bit integers. By default,
this is enabled on x86, x86-64,
32/64-bit big endian PowerPC,
64-bit little endian PowerPC,
and some ARM, ARM64, and RISC-V systems.]),
[], [enable_unaligned_access=auto])
if test "x$enable_unaligned_access" = xauto ; then
# TODO: There may be other architectures, on which unaligned access
# is OK.
# NOTE: There might be other architectures on which unaligned access
# is fast.
case $host_cpu in
i?86|x86_64|powerpc|powerpc64)
i?86|x86_64|powerpc|powerpc64|powerpc64le)
enable_unaligned_access=yes
;;
arm*|aarch64*|riscv*)
# On 32-bit and 64-bit ARM, GCC and Clang
# #define __ARM_FEATURE_UNALIGNED if
# unaligned access is supported.
#
# Exception: GCC at least up to 13.2.0
# defines it even when using -mstrict-align
# so in that case this autodetection goes wrong.
# Most of the time -mstrict-align isn't used so it
# shouldn't be a common problem in practice. See:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111555
#
# RISC-V C API Specification says that if
# __riscv_misaligned_fast is defined then
# unaligned access is known to be fast.
#
# MSVC is handled as a special case: We assume that
# 32/64-bit ARM supports fast unaligned access.
# If MSVC gets RISC-V support then this will assume
# fast unaligned access on RISC-V too.
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#if !defined(__ARM_FEATURE_UNALIGNED) \
&& !defined(__riscv_misaligned_fast) \
&& !defined(_MSC_VER)
compile error
#endif
int main(void) { return 0; }
])], [enable_unaligned_access=yes], [enable_unaligned_access=no])
;;
*)
enable_unaligned_access=no
;;
@ -65,10 +114,39 @@ if test "x$enable_unaligned_access" = xauto ; then
fi
if test "x$enable_unaligned_access" = xyes ; then
AC_DEFINE([TUKLIB_FAST_UNALIGNED_ACCESS], [1], [Define to 1 if
the system supports fast unaligned access to 16-bit and
32-bit integers.])
the system supports fast unaligned access to 16-bit,
32-bit, and 64-bit integers.])
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
AC_MSG_CHECKING([if unsafe type punning should be used])
AC_ARG_ENABLE([unsafe-type-punning],
AS_HELP_STRING([--enable-unsafe-type-punning],
[This introduces strict aliasing violations and may result
in broken code. However, this might improve performance in
some cases, especially with old compilers (e.g.
GCC 3 and early 4.x on x86, GCC < 6 on ARMv6 and ARMv7).]),
[], [enable_unsafe_type_punning=no])
if test "x$enable_unsafe_type_punning" = xyes ; then
AC_DEFINE([TUKLIB_USE_UNSAFE_TYPE_PUNNING], [1], [Define to 1 to use
unsafe type punning, e.g. char *x = ...; *(int *)x = 123;
which violates strict aliasing rules and thus is
undefined behavior and might result in broken code.])
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
AC_MSG_CHECKING([if __builtin_assume_aligned is supported])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[__builtin_assume_aligned("", 1);]])],
[
AC_DEFINE([HAVE___BUILTIN_ASSUME_ALIGNED], [1],
[Define to 1 if the GNU C extension
__builtin_assume_aligned is supported.])
AC_MSG_RESULT([yes])
], [
AC_MSG_RESULT([no])
])
])dnl

View File

@ -1,3 +1,6 @@
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# SYNOPSIS
#
@ -15,13 +18,11 @@
# functions, but each function is put into a separate .c file so
# that it is possible to pick only what is strictly needed.
#
# COPYING
#############################################################################
#
# Author: Lasse Collin
#
# This file has been put into the public domain.
# You can do whatever you want with this file.
# Author: Lasse Collin
#
#############################################################################
AC_DEFUN_ONCE([TUKLIB_MBSTR], [
AC_REQUIRE([TUKLIB_COMMON])

View File

@ -1,3 +1,6 @@
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# SYNOPSIS
#
@ -10,8 +13,8 @@
#
# Supported methods:
#
# - Windows (including Cygwin), OS/2, DJGPP (DOS), and OpenVMS have
# operating-system specific functions.
# - Windows (including Cygwin), OS/2, DJGPP (DOS), OpenVMS, AROS,
# and QNX have operating-system specific functions.
#
# - AIX has _system_configuration.physmem.
#
@ -29,13 +32,11 @@
# - sysinfo() works on Linux/dietlibc and probably on other Linux
# systems whose libc may lack sysconf().
#
# COPYING
#############################################################################
#
# Author: Lasse Collin
#
# This file has been put into the public domain.
# You can do whatever you want with this file.
# Author: Lasse Collin
#
#############################################################################
AC_DEFUN_ONCE([TUKLIB_PHYSMEM], [
AC_REQUIRE([TUKLIB_COMMON])
@ -53,7 +54,8 @@ AC_CACHE_CHECK([how to detect the amount of physical memory],
# a non-compilable text instead of #error to generate an error.
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__OS2__) \
|| defined(__DJGPP__) || defined(__VMS)
|| defined(__DJGPP__) || defined(__VMS) \
|| defined(AMIGA) || defined(__AROS__) || defined(__QNX__)
int main(void) { return 0; }
#else
compile error
@ -87,7 +89,6 @@ main(void)
]])], [tuklib_cv_physmem_method=sysconf], [
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <sys/types.h>
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif

View File

@ -1,3 +1,6 @@
# SPDX-License-Identifier: 0BSD
#############################################################################
#
# SYNOPSIS
#
@ -11,15 +14,16 @@
# This .m4 file is needed allow this module to use glibc's
# program_invocation_name.
#
# COPYING
#############################################################################
#
# Author: Lasse Collin
#
# This file has been put into the public domain.
# You can do whatever you want with this file.
# Author: Lasse Collin
#
#############################################################################
AC_DEFUN_ONCE([TUKLIB_PROGNAME], [
AC_REQUIRE([TUKLIB_COMMON])
AC_CHECK_DECLS([program_invocation_name], [], [], [#include <errno.h>])
AC_CHECK_DECL([program_invocation_name], [AC_DEFINE(
[HAVE_PROGRAM_INVOCATION_NAME], [1],
[Define to 1 if 'program_invocation_name' is declared in <errno.h>.])],
[], [#include <errno.h>])
])dnl

84
m4/visibility.m4 Normal file
View File

@ -0,0 +1,84 @@
dnl SPDX-License-Identifier: FSFULLR
# visibility.m4 serial 8
dnl Copyright (C) 2005, 2008, 2010-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
dnl Tests whether the compiler supports the command-line option
dnl -fvisibility=hidden and the function and variable attributes
dnl __attribute__((__visibility__("hidden"))) and
dnl __attribute__((__visibility__("default"))).
dnl Does *not* test for __visibility__("protected") - which has tricky
dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on
dnl Mac OS X.
dnl Does *not* test for __visibility__("internal") - which has processor
dnl dependent semantics.
dnl Does *not* test for #pragma GCC visibility push(hidden) - which is
dnl "really only recommended for legacy code".
dnl Set the variable CFLAG_VISIBILITY.
dnl Defines and sets the variable HAVE_VISIBILITY.
AC_DEFUN([gl_VISIBILITY],
[
AC_REQUIRE([AC_PROG_CC])
CFLAG_VISIBILITY=
HAVE_VISIBILITY=0
if test -n "$GCC"; then
dnl First, check whether -Werror can be added to the command line, or
dnl whether it leads to an error because of some other option that the
dnl user has put into $CC $CFLAGS $CPPFLAGS.
AC_CACHE_CHECK([whether the -Werror option is usable],
[gl_cv_cc_vis_werror],
[gl_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[]], [[]])],
[gl_cv_cc_vis_werror=yes],
[gl_cv_cc_vis_werror=no])
CFLAGS="$gl_save_CFLAGS"
])
dnl Now check whether visibility declarations are supported.
AC_CACHE_CHECK([for simple visibility declarations],
[gl_cv_cc_visibility],
[gl_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fvisibility=hidden"
dnl We use the option -Werror and a function dummyfunc, because on some
dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning
dnl "visibility attribute not supported in this configuration; ignored"
dnl at the first function definition in every compilation unit, and we
dnl don't want to use the option in this case.
if test $gl_cv_cc_vis_werror = yes; then
CFLAGS="$CFLAGS -Werror"
fi
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[extern __attribute__((__visibility__("hidden"))) int hiddenvar;
extern __attribute__((__visibility__("default"))) int exportedvar;
extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
extern __attribute__((__visibility__("default"))) int exportedfunc (void);
void dummyfunc (void);
int hiddenvar;
int exportedvar;
int hiddenfunc (void) { return 51; }
int exportedfunc (void) { return 1225736919; }
void dummyfunc (void) {}
]],
[[]])],
[gl_cv_cc_visibility=yes],
[gl_cv_cc_visibility=no])
CFLAGS="$gl_save_CFLAGS"
])
if test $gl_cv_cc_visibility = yes; then
CFLAG_VISIBILITY="-fvisibility=hidden"
HAVE_VISIBILITY=1
fi
fi
AC_SUBST([CFLAG_VISIBILITY])
AC_SUBST([HAVE_VISIBILITY])
AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY],
[Define to 1 or 0, depending whether the compiler supports simple visibility declarations.])
])

View File

@ -1,3 +1,23 @@
ca
cs
da
de
eo
es
fi
fr
hr
hu
it
ko
pl
pt
pt_BR
ro
sr
sv
tr
uk
vi
zh_CN
zh_TW

View File

@ -1,4 +1,10 @@
# SPDX-License-Identifier: FSFUL
# Makefile variables for PO directory in any package using GNU gettext.
#
# Copyright (C) 2003-2019 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation gives
# unlimited permission to use, copy, distribute, and modify it.
# Usually the message domain is the same as the package name.
DOMAIN = $(PACKAGE)
@ -8,7 +14,7 @@ subdir = po
top_builddir = ..
# These options get passed to xgettext.
XGETTEXT_OPTIONS = --keyword=_ --keyword=N_
XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --no-wrap --package-name='XZ Utils'
# This is the copyright holder that gets inserted into the header of the
# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
@ -18,7 +24,14 @@ XGETTEXT_OPTIONS = --keyword=_ --keyword=N_
# or entity, or to disclaim their copyright. The empty string stands for
# the public domain; in this case the translators are expected to disclaim
# their copyright.
COPYRIGHT_HOLDER =
COPYRIGHT_HOLDER = The XZ Utils authors and contributors
# This tells whether or not to prepend "GNU " prefix to the package
# name that gets inserted into the header of the $(DOMAIN).pot file.
# Possible values are "yes", "no", or empty. If it is empty, try to
# detect it automatically by scanning the files in $(top_srcdir) for
# "GNU packagename" string.
PACKAGE_GNU = no
# This is the email address or URL to which the translators shall report
# bugs in the untranslated strings:
@ -40,7 +53,35 @@ MSGID_BUGS_ADDRESS =
# message catalogs shall be used. It is usually empty.
EXTRA_LOCALE_CATEGORIES =
# Although you may need slightly wider terminal than 80 chars, it is
# much nicer to edit the output of --help when this is set.
XGETTEXT_OPTIONS += --no-wrap
MSGMERGE += --no-wrap
# This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
# context. Possible values are "yes" and "no". Set this to yes if the
# package uses functions taking also a message context, like pgettext(), or
# if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
USE_MSGCTXT = no
# These options get passed to msgmerge.
# Useful options are in particular:
# --previous to keep previous msgids of translated messages,
# --quiet to reduce the verbosity.
MSGMERGE_OPTIONS = --no-wrap
# These options get passed to msginit.
# If you want to disable line wrapping when writing PO files, add
# --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and
# MSGINIT_OPTIONS.
#
# Although one may need slightly wider terminal than 80 chars, it is
# much nicer to edit the output of --help when --no-wrap is set.
MSGINIT_OPTIONS = --no-wrap
# This tells whether or not to regenerate a PO file when $(DOMAIN).pot
# has changed. Possible values are "yes" and "no". Set this to no if
# the POT file is checked in the repository and the version control
# program ignores timestamps.
PO_DEPENDS_ON_POT = yes
# This tells whether or not to forcibly update $(DOMAIN).pot and
# regenerate PO files on "make dist". Possible values are "yes" and
# "no". Set this to no if the POT file and PO files are maintained
# externally.
DIST_DEPENDS_ON_UPDATE_PO = yes

View File

@ -1,3 +1,5 @@
# SPDX-License-Identifier: 0BSD
# List of source files which contain translatable strings.
src/xz/args.c
src/xz/coder.c
@ -6,8 +8,10 @@ src/xz/hardware.c
src/xz/list.c
src/xz/main.c
src/xz/message.c
src/xz/mytime.c
src/xz/options.c
src/xz/signals.c
src/xz/suffix.c
src/xz/util.c
src/lzmainfo/lzmainfo.c
src/common/tuklib_exit.c

1031
po/ca.po Normal file

File diff suppressed because it is too large Load Diff

596
po/cs.po

File diff suppressed because it is too large Load Diff

896
po/da.po Normal file
View File

@ -0,0 +1,896 @@
# Danish translation xz.
# This file is put in the public domain.
# Joe Hansen <joedalton2@yahoo.dk>, 2019.
#
msgid ""
msgstr ""
"Project-Id-Version: xz 5.2.4\n"
"Report-Msgid-Bugs-To: lasse.collin@tukaani.org\n"
"POT-Creation-Date: 2018-04-29 18:19+0300\n"
"PO-Revision-Date: 2019-03-04 23:08+0100\n"
"Last-Translator: Joe Hansen <joedalton2@yahoo.dk>\n"
"Language-Team: Danish <dansk@dansk-gruppen.dk>\n"
"Language: da\n"
"X-Bugs: Report translation errors to the Language-Team address.\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: src/xz/args.c:63
#, c-format
msgid "%s: Invalid argument to --block-list"
msgstr "%s: Ugyldigt parameter til --block-list"
#: src/xz/args.c:73
#, c-format
msgid "%s: Too many arguments to --block-list"
msgstr "%s: For mange argumenter til --block-list"
#: src/xz/args.c:102
msgid "0 can only be used as the last element in --block-list"
msgstr "0 kan kun bruges som det sidste element i --block-list"
#: src/xz/args.c:406
#, c-format
msgid "%s: Unknown file format type"
msgstr "%s: Ukendt filformattype"
#: src/xz/args.c:429 src/xz/args.c:437
#, c-format
msgid "%s: Unsupported integrity check type"
msgstr "%s: Typen for integritetkontrol er ikke understøttet"
#: src/xz/args.c:473
msgid "Only one file can be specified with `--files' or `--files0'."
msgstr "Kun en fil kan angives med »--files« eller »--files0«."
#: src/xz/args.c:541
#, c-format
msgid "The environment variable %s contains too many arguments"
msgstr "Miljøvariablen %s indeholder for mange argumenter"
#: src/xz/args.c:643
msgid "Compression support was disabled at build time"
msgstr "Komprimeringsunderstøttelse blev deaktiveret på byggetidspunktet"
#: src/xz/args.c:650
msgid "Decompression support was disabled at build time"
msgstr "Dekomprimeringsunderstøttelse blev deaktiveret på byggetidspunktet"
#: src/xz/coder.c:110
msgid "Maximum number of filters is four"
msgstr "Maksimalt antal filtre er fire"
#: src/xz/coder.c:129
msgid "Memory usage limit is too low for the given filter setup."
msgstr "Begræsningen for brug af hukommelse er for lav for den givne filteropsætning."
#: src/xz/coder.c:159
msgid "Using a preset in raw mode is discouraged."
msgstr "Det frarådes at bruge en forhåndskonfiguration i rå tilstand (raw mode)."
#: src/xz/coder.c:161
msgid "The exact options of the presets may vary between software versions."
msgstr "De præcise indstillinger for forhåndskonfigurationerne kan variere mellem programversioner."
#: src/xz/coder.c:184
msgid "The .lzma format supports only the LZMA1 filter"
msgstr "Formatet .lzma understøtter kun LZMA1-filteret"
#: src/xz/coder.c:192
msgid "LZMA1 cannot be used with the .xz format"
msgstr "LZMA1 kan ikke bruges med .xz-formatet"
#: src/xz/coder.c:209
msgid "The filter chain is incompatible with --flush-timeout"
msgstr "Filterkæden er ikke kompatibel med --flush-timeout"
#: src/xz/coder.c:215
msgid "Switching to single-threaded mode due to --flush-timeout"
msgstr "Skifter til enkelt trådet tilstand på grund af --flush-timeout"
#: src/xz/coder.c:235
#, c-format
msgid "Using up to %<PRIu32> threads."
msgstr "Bruger op til %<PRIu32> tråde."
#: src/xz/coder.c:251
msgid "Unsupported filter chain or filter options"
msgstr "Filterkæde eller filterindstillinger er ikke understøttet"
#: src/xz/coder.c:263
#, c-format
msgid "Decompression will need %s MiB of memory."
msgstr "Dekomprimering vil kræve %s MiB hukommelse."
#: src/xz/coder.c:300
#, c-format
msgid "Adjusted the number of threads from %s to %s to not exceed the memory usage limit of %s MiB"
msgstr "Justerede antallet af tråde fra %s til %s for ikke at overskride begræsningen på brug af hukommelse på %s MiB"
#: src/xz/coder.c:354
#, c-format
msgid "Adjusted LZMA%c dictionary size from %s MiB to %s MiB to not exceed the memory usage limit of %s MiB"
msgstr "Justerede LZMA%c-ordbogsstørrelsen fra %s MiB til %s MiB for ikke at overskride begrænsningen på brug af hukommelse på %s MiB"
#: src/xz/file_io.c:110 src/xz/file_io.c:118
#, c-format
msgid "Error creating a pipe: %s"
msgstr "Det opstod en fejl under oprettelse af en datakanal: %s"
#: src/xz/file_io.c:173
msgid "Sandbox is disabled due to incompatible command line arguments"
msgstr "Sandkassen er deaktiveret på grund af inkompatible kommandolinjeargumenter"
#: src/xz/file_io.c:216
msgid "Sandbox was successfully enabled"
msgstr "Sandkassen blev aktiveret"
#: src/xz/file_io.c:220
msgid "Failed to enable the sandbox"
msgstr "Kunne ikke aktivere sandkassen"
#: src/xz/file_io.c:262
#, c-format
msgid "%s: poll() failed: %s"
msgstr "%s: poll() mislykkedes: %s"
#. TRANSLATORS: When compression or decompression finishes,
#. and xz is going to remove the source file, xz first checks
#. if the source file still exists, and if it does, does its
#. device and inode numbers match what xz saw when it opened
#. the source file. If these checks fail, this message is
#. shown, %s being the filename, and the file is not deleted.
#. The check for device and inode numbers is there, because
#. it is possible that the user has put a new file in place
#. of the original file, and in that case it obviously
#. shouldn't be removed.
#: src/xz/file_io.c:332
#, c-format
msgid "%s: File seems to have been moved, not removing"
msgstr "%s: Filen er vist blevet flyttet, sletter ikke"
#: src/xz/file_io.c:339 src/xz/file_io.c:878
#, c-format
msgid "%s: Cannot remove: %s"
msgstr "%s: Kan ikke fjerne: %s"
#: src/xz/file_io.c:364
#, c-format
msgid "%s: Cannot set the file owner: %s"
msgstr "%s: Kan ikke angive filejeren: %s"
#: src/xz/file_io.c:370
#, c-format
msgid "%s: Cannot set the file group: %s"
msgstr "%s: Kan ikke angive filgruppen: %s"
#: src/xz/file_io.c:389
#, c-format
msgid "%s: Cannot set the file permissions: %s"
msgstr "%s: Kan ikke angive filtilladelser: %s"
#: src/xz/file_io.c:515
#, c-format
msgid "Error getting the file status flags from standard input: %s"
msgstr "Der opstod en fejl under indhentelse af filstatusflag fra standardind: %s"
#: src/xz/file_io.c:572 src/xz/file_io.c:634
#, c-format
msgid "%s: Is a symbolic link, skipping"
msgstr "%s: Er en symbolsk henvisning, udelader"
#: src/xz/file_io.c:663
#, c-format
msgid "%s: Is a directory, skipping"
msgstr "%s: Er en mappe, udelader"
#: src/xz/file_io.c:669
#, c-format
msgid "%s: Not a regular file, skipping"
msgstr "%s: Er ikke en normal fil, udelader"
#: src/xz/file_io.c:686
#, c-format
msgid "%s: File has setuid or setgid bit set, skipping"
msgstr "%s: Filen har setuid- eller setgid-bitsæt, udelader"
#: src/xz/file_io.c:693
#, c-format
msgid "%s: File has sticky bit set, skipping"
msgstr "%s: Fil har klæbende bitsæt, udelader"
#: src/xz/file_io.c:700
#, c-format
msgid "%s: Input file has more than one hard link, skipping"
msgstr "%s: Inddatafil har mere end en hård henvisning, udelader"
#: src/xz/file_io.c:788
#, c-format
msgid "Error restoring the status flags to standard input: %s"
msgstr "Der opstod en fejl under gendannelse af statusflagene til standardind: %s"
#: src/xz/file_io.c:836
#, c-format
msgid "Error getting the file status flags from standard output: %s"
msgstr "Der opstod en fejl under indhentelse af filstatusflag fra standardud: %s"
#: src/xz/file_io.c:1014
#, c-format
msgid "Error restoring the O_APPEND flag to standard output: %s"
msgstr "Der opstod en fejl under gendannelse af flaget O_APPEND til standardud: %s"
#: src/xz/file_io.c:1026
#, c-format
msgid "%s: Closing the file failed: %s"
msgstr "%s: Lukning af filen fejlede: %s"
#: src/xz/file_io.c:1062 src/xz/file_io.c:1288
#, c-format
msgid "%s: Seeking failed when trying to create a sparse file: %s"
msgstr "%s: Søgning fejlede under forsøg på at oprette en tynd fil: %s"
#: src/xz/file_io.c:1157
#, c-format
msgid "%s: Read error: %s"
msgstr "%s: Læsefejl: %s"
#: src/xz/file_io.c:1177
#, c-format
msgid "%s: Error seeking the file: %s"
msgstr "%s: Der opstod en fejl under søgning efter filen: %s"
#: src/xz/file_io.c:1187
#, c-format
msgid "%s: Unexpected end of file"
msgstr "%s: Uventet filafslutning"
#: src/xz/file_io.c:1246
#, c-format
msgid "%s: Write error: %s"
msgstr "%s: Skrivefejl: %s"
#: src/xz/hardware.c:107
msgid "Disabled"
msgstr "Deaktiveret"
#. TRANSLATORS: Test with "xz --info-memory" to see if
#. the alignment looks nice.
#: src/xz/hardware.c:126
msgid "Total amount of physical memory (RAM): "
msgstr "Samlet mængde fysisk hukommelse (RAM): "
#: src/xz/hardware.c:128
msgid "Memory usage limit for compression: "
msgstr "Grænse for hukommelsesforbrug til komprimering: "
#: src/xz/hardware.c:130
msgid "Memory usage limit for decompression: "
msgstr "Grænse for hukommelsesforbug til dekomprimering: "
#. TRANSLATORS: Indicates that there is no integrity check.
#. This string is used in tables, so the width must not
#. exceed ten columns with a fixed-width font.
#: src/xz/list.c:65
msgid "None"
msgstr "Ingen"
#. TRANSLATORS: Indicates that integrity check name is not known,
#. but the Check ID is known (here 2). This and other "Unknown-N"
#. strings are used in tables, so the width must not exceed ten
#. columns with a fixed-width font. It's OK to omit the dash if
#. you need space for one extra letter, but don't use spaces.
#: src/xz/list.c:72
msgid "Unknown-2"
msgstr "Ukendt-2"
#: src/xz/list.c:73
msgid "Unknown-3"
msgstr "Ukendt-3"
#: src/xz/list.c:75
msgid "Unknown-5"
msgstr "Ukendt-5"
#: src/xz/list.c:76
msgid "Unknown-6"
msgstr "Ukendt-6"
#: src/xz/list.c:77
msgid "Unknown-7"
msgstr "Ukendt-7"
#: src/xz/list.c:78
msgid "Unknown-8"
msgstr "Ukendt-8"
#: src/xz/list.c:79
msgid "Unknown-9"
msgstr "Ukendt-9"
#: src/xz/list.c:81
msgid "Unknown-11"
msgstr "Ukendt-11"
#: src/xz/list.c:82
msgid "Unknown-12"
msgstr "Ukendt-12"
#: src/xz/list.c:83
msgid "Unknown-13"
msgstr "Ukendt-13"
#: src/xz/list.c:84
msgid "Unknown-14"
msgstr "Ukendt-14"
#: src/xz/list.c:85
msgid "Unknown-15"
msgstr "Ukendt-15"
#: src/xz/list.c:153
#, c-format
msgid "%s: File is empty"
msgstr "%s: Filen er tom"
#: src/xz/list.c:158
#, c-format
msgid "%s: Too small to be a valid .xz file"
msgstr "%s: For lille til at være en gyldig .xz-fil"
#. TRANSLATORS: These are column headings. From Strms (Streams)
#. to Ratio, the columns are right aligned. Check and Filename
#. are left aligned. If you need longer words, it's OK to
#. use two lines here. Test with "xz -l foo.xz".
#: src/xz/list.c:677
msgid "Strms Blocks Compressed Uncompressed Ratio Check Filename"
msgstr ""
#: src/xz/list.c:717
#, c-format
msgid " Streams: %s\n"
msgstr " Strømme: %s\n"
#: src/xz/list.c:719
#, c-format
msgid " Blocks: %s\n"
msgstr " Blokke: %s\n"
#: src/xz/list.c:721
#, c-format
msgid " Compressed size: %s\n"
msgstr " Komprimeret str.: %s\n"
#: src/xz/list.c:724
#, c-format
msgid " Uncompressed size: %s\n"
msgstr " Ukomprimeret str.: %s\n"
#: src/xz/list.c:727
#, c-format
msgid " Ratio: %s\n"
msgstr " Pakkeforhold: %s\n"
#: src/xz/list.c:729
#, c-format
msgid " Check: %s\n"
msgstr " Kontrol: %s\n"
#: src/xz/list.c:730
#, c-format
msgid " Stream padding: %s\n"
msgstr " Strømfyld: %s\n"
#. TRANSLATORS: The second line is column headings. All except
#. Check are right aligned; Check is left aligned. Test with
#. "xz -lv foo.xz".
#: src/xz/list.c:758
msgid ""
" Streams:\n"
" Stream Blocks CompOffset UncompOffset CompSize UncompSize Ratio Check Padding"
msgstr ""
" Strømme:\n"
" Strøm Blokke KompForsk. DekompForsk. KompStr. DekompStr. Forh. Kontrol Fyld"
#. TRANSLATORS: The second line is column headings. All
#. except Check are right aligned; Check is left aligned.
#: src/xz/list.c:813
#, c-format
msgid ""
" Blocks:\n"
" Stream Block CompOffset UncompOffset TotalSize UncompSize Ratio Check"
msgstr ""
" Blokke:\n"
" Strøm Blok KompForsk. DekompForsk. Ialtstr. DekompStr. Forh. Kontrol"
#. TRANSLATORS: These are additional column headings
#. for the most verbose listing mode. CheckVal
#. (Check value), Flags, and Filters are left aligned.
#. Header (Block Header Size), CompSize, and MemUsage
#. are right aligned. %*s is replaced with 0-120
#. spaces to make the CheckVal column wide enough.
#. Test with "xz -lvv foo.xz".
#: src/xz/list.c:825
#, c-format
msgid " CheckVal %*s Header Flags CompSize MemUsage Filters"
msgstr " KontrolVær %*sTeksth Flag Kompstr. HukForb. Filtre"
#: src/xz/list.c:903 src/xz/list.c:1078
#, c-format
msgid " Memory needed: %s MiB\n"
msgstr " Hukommelse krævet: %s MiB\n"
#: src/xz/list.c:905 src/xz/list.c:1080
#, c-format
msgid " Sizes in headers: %s\n"
msgstr " Størrelser i teksthoveder: %s\n"
#: src/xz/list.c:906 src/xz/list.c:1081
msgid "Yes"
msgstr "Ja"
#: src/xz/list.c:906 src/xz/list.c:1081
msgid "No"
msgstr "Nej"
#: src/xz/list.c:907 src/xz/list.c:1082
#, c-format
msgid " Minimum XZ Utils version: %s\n"
msgstr " Minimum for XZ Utils-version: %s\n"
#. TRANSLATORS: %s is an integer. Only the plural form of this
#. message is used (e.g. "2 files"). Test with "xz -l foo.xz bar.xz".
#: src/xz/list.c:1057
#, c-format
msgid "%s file\n"
msgid_plural "%s files\n"
msgstr[0] "%s fil\n"
msgstr[1] "%s filer\n"
#: src/xz/list.c:1070
msgid "Totals:"
msgstr "I alt:"
#: src/xz/list.c:1071
#, c-format
msgid " Number of files: %s\n"
msgstr " Antal filer: %s\n"
#: src/xz/list.c:1146
msgid "--list works only on .xz files (--format=xz or --format=auto)"
msgstr ""
#: src/xz/list.c:1152
msgid "--list does not support reading from standard input"
msgstr "--list understøtter ikke læsning fra standardind"
#: src/xz/main.c:89
#, c-format
msgid "%s: Error reading filenames: %s"
msgstr "%s: Der opstod en fejl under forsøg på læsning af filnavne: %s"
#: src/xz/main.c:96
#, c-format
msgid "%s: Unexpected end of input when reading filenames"
msgstr "%s: Uventet afslutning på inddata under forsøg på læsning af filnavne"
#: src/xz/main.c:120
#, c-format
msgid "%s: Null character found when reading filenames; maybe you meant to use `--files0' instead of `--files'?"
msgstr ""
#: src/xz/main.c:174
msgid "Compression and decompression with --robot are not supported yet."
msgstr "Komprimering og dekomprimering med --robot er endnu ikke understøttet."
#: src/xz/main.c:252
msgid "Cannot read data from standard input when reading filenames from standard input"
msgstr ""
#. TRANSLATORS: This is the program name in the beginning
#. of the line in messages. Usually it becomes "xz: ".
#. This is a translatable string because French needs
#. a space before a colon.
#: src/xz/message.c:714
#, c-format
msgid "%s: "
msgstr "%s: "
#: src/xz/message.c:777 src/xz/message.c:827
msgid "Internal error (bug)"
msgstr "Intern fejl (fejl)"
#: src/xz/message.c:784
msgid "Cannot establish signal handlers"
msgstr "Kan ikke etbalere signalhåndteringer"
#: src/xz/message.c:793
msgid "No integrity check; not verifying file integrity"
msgstr "Ingen integritetkontrol; verificerer ikke filintegritet"
#: src/xz/message.c:796
msgid "Unsupported type of integrity check; not verifying file integrity"
msgstr ""
#: src/xz/message.c:803
msgid "Memory usage limit reached"
msgstr "Begrænsning på brug af hukommelse er nået"
#: src/xz/message.c:806
msgid "File format not recognized"
msgstr "Filformatet blev ikke genkendt"
#: src/xz/message.c:809
msgid "Unsupported options"
msgstr "Tilvalg er ikke understøttede"
#: src/xz/message.c:812
msgid "Compressed data is corrupt"
msgstr "Komprimerede data er ødelagte"
#: src/xz/message.c:815
msgid "Unexpected end of input"
msgstr "Uventet afslutning på inddata"
#: src/xz/message.c:848
#, c-format
msgid "%s MiB of memory is required. The limiter is disabled."
msgstr "%s MiB hukommelse er krævet. Begrænseren er deaktiveret."
#: src/xz/message.c:876
#, c-format
msgid "%s MiB of memory is required. The limit is %s."
msgstr "%s MiB hukommelse er krævet. Begrænsningen er %s."
#: src/xz/message.c:1043
#, c-format
msgid "%s: Filter chain: %s\n"
msgstr "%s: Filterkæde: %s\n"
#: src/xz/message.c:1053
#, c-format
msgid "Try `%s --help' for more information."
msgstr "Prøv »%s --help« for yderligere information."
#: src/xz/message.c:1079
#, c-format
msgid ""
"Usage: %s [OPTION]... [FILE]...\n"
"Compress or decompress FILEs in the .xz format.\n"
"\n"
msgstr ""
#: src/xz/message.c:1086
msgid "Mandatory arguments to long options are mandatory for short options too.\n"
msgstr ""
"Obligatoriske argumenter til lange tilvalg er også obligatoriske for korte\n"
"tilvalg.\n"
#: src/xz/message.c:1090
msgid " Operation mode:\n"
msgstr " Operationstilstand:\n"
#: src/xz/message.c:1093
msgid ""
" -z, --compress force compression\n"
" -d, --decompress force decompression\n"
" -t, --test test compressed file integrity\n"
" -l, --list list information about .xz files"
msgstr ""
#: src/xz/message.c:1099
msgid ""
"\n"
" Operation modifiers:\n"
msgstr ""
"\n"
"Operationsændrere:\n"
#: src/xz/message.c:1102
msgid ""
" -k, --keep keep (don't delete) input files\n"
" -f, --force force overwrite of output file and (de)compress links\n"
" -c, --stdout write to standard output and don't delete input files"
msgstr ""
#: src/xz/message.c:1108
msgid ""
" --single-stream decompress only the first stream, and silently\n"
" ignore possible remaining input data"
msgstr ""
#: src/xz/message.c:1111
msgid ""
" --no-sparse do not create sparse files when decompressing\n"
" -S, --suffix=.SUF use the suffix `.SUF' on compressed files\n"
" --files[=FILE] read filenames to process from FILE; if FILE is\n"
" omitted, filenames are read from the standard input;\n"
" filenames must be terminated with the newline character\n"
" --files0[=FILE] like --files but use the null character as terminator"
msgstr ""
#: src/xz/message.c:1120
msgid ""
"\n"
" Basic file format and compression options:\n"
msgstr ""
#: src/xz/message.c:1122
msgid ""
" -F, --format=FMT file format to encode or decode; possible values are\n"
" `auto' (default), `xz', `lzma', and `raw'\n"
" -C, --check=CHECK integrity check type: `none' (use with caution),\n"
" `crc32', `crc64' (default), or `sha256'"
msgstr ""
#: src/xz/message.c:1127
msgid " --ignore-check don't verify the integrity check when decompressing"
msgstr ""
#: src/xz/message.c:1131
msgid ""
" -0 ... -9 compression preset; default is 6; take compressor *and*\n"
" decompressor memory usage into account before using 7-9!"
msgstr ""
#: src/xz/message.c:1135
msgid ""
" -e, --extreme try to improve compression ratio by using more CPU time;\n"
" does not affect decompressor memory requirements"
msgstr ""
#: src/xz/message.c:1139
msgid ""
" -T, --threads=NUM use at most NUM threads; the default is 1; set to 0\n"
" to use as many threads as there are processor cores"
msgstr ""
#: src/xz/message.c:1144
msgid ""
" --block-size=SIZE\n"
" start a new .xz block after every SIZE bytes of input;\n"
" use this to set the block size for threaded compression"
msgstr ""
#: src/xz/message.c:1148
msgid ""
" --block-list=SIZES\n"
" start a new .xz block after the given comma-separated\n"
" intervals of uncompressed data"
msgstr ""
#: src/xz/message.c:1152
msgid ""
" --flush-timeout=TIMEOUT\n"
" when compressing, if more than TIMEOUT milliseconds has\n"
" passed since the previous flush and reading more input\n"
" would block, all pending data is flushed out"
msgstr ""
#: src/xz/message.c:1158
#, no-c-format
msgid ""
" --memlimit-compress=LIMIT\n"
" --memlimit-decompress=LIMIT\n"
" -M, --memlimit=LIMIT\n"
" set memory usage limit for compression, decompression,\n"
" or both; LIMIT is in bytes, % of RAM, or 0 for defaults"
msgstr ""
#: src/xz/message.c:1165
msgid ""
" --no-adjust if compression settings exceed the memory usage limit,\n"
" give an error instead of adjusting the settings downwards"
msgstr ""
#: src/xz/message.c:1171
msgid ""
"\n"
" Custom filter chain for compression (alternative for using presets):"
msgstr ""
#: src/xz/message.c:1180
msgid ""
"\n"
" --lzma1[=OPTS] LZMA1 or LZMA2; OPTS is a comma-separated list of zero or\n"
" --lzma2[=OPTS] more of the following options (valid values; default):\n"
" preset=PRE reset options to a preset (0-9[e])\n"
" dict=NUM dictionary size (4KiB - 1536MiB; 8MiB)\n"
" lc=NUM number of literal context bits (0-4; 3)\n"
" lp=NUM number of literal position bits (0-4; 0)\n"
" pb=NUM number of position bits (0-4; 2)\n"
" mode=MODE compression mode (fast, normal; normal)\n"
" nice=NUM nice length of a match (2-273; 64)\n"
" mf=NAME match finder (hc3, hc4, bt2, bt3, bt4; bt4)\n"
" depth=NUM maximum search depth; 0=automatic (default)"
msgstr ""
#: src/xz/message.c:1195
msgid ""
"\n"
" --x86[=OPTS] x86 BCJ filter (32-bit and 64-bit)\n"
" --powerpc[=OPTS] PowerPC BCJ filter (big endian only)\n"
" --ia64[=OPTS] IA-64 (Itanium) BCJ filter\n"
" --arm[=OPTS] ARM BCJ filter (little endian only)\n"
" --armthumb[=OPTS] ARM-Thumb BCJ filter (little endian only)\n"
" --sparc[=OPTS] SPARC BCJ filter\n"
" Valid OPTS for all BCJ filters:\n"
" start=NUM start offset for conversions (default=0)"
msgstr ""
#: src/xz/message.c:1207
msgid ""
"\n"
" --delta[=OPTS] Delta filter; valid OPTS (valid values; default):\n"
" dist=NUM distance between bytes being subtracted\n"
" from each other (1-256; 1)"
msgstr ""
#: src/xz/message.c:1215
msgid ""
"\n"
" Other options:\n"
msgstr ""
"\n"
"Andre tilvalg:\n"
#: src/xz/message.c:1218
msgid ""
" -q, --quiet suppress warnings; specify twice to suppress errors too\n"
" -v, --verbose be verbose; specify twice for even more verbose"
msgstr ""
#: src/xz/message.c:1223
msgid " -Q, --no-warn make warnings not affect the exit status"
msgstr ""
#: src/xz/message.c:1225
msgid " --robot use machine-parsable messages (useful for scripts)"
msgstr ""
" --robot brug beskeder der kan fortolkes maskinelt (nyttigt\n"
" for skripter)"
#: src/xz/message.c:1228
msgid ""
" --info-memory display the total amount of RAM and the currently active\n"
" memory usage limits, and exit"
msgstr ""
#: src/xz/message.c:1231
msgid ""
" -h, --help display the short help (lists only the basic options)\n"
" -H, --long-help display this long help and exit"
msgstr ""
" -h, --help vis den korte hjælpetekst (viser kun grundlæggende\n"
" tilvalg)\n"
" -H, --long-help vis den lange hjælpetekst og afslut"
#: src/xz/message.c:1235
msgid ""
" -h, --help display this short help and exit\n"
" -H, --long-help display the long help (lists also the advanced options)"
msgstr ""
" -h, --help vis den korte hjælpetekst og afslut\n"
" -H, --long-help vis den lange hjælpetekst (viser også de avancerede\n"
" tilvalg)"
#: src/xz/message.c:1240
msgid " -V, --version display the version number and exit"
msgstr " -V, --version vis versionsnummer og afslut"
#: src/xz/message.c:1242
msgid ""
"\n"
"With no FILE, or when FILE is -, read standard input.\n"
msgstr ""
"\n"
"Med ingen FIL, eller når FIL er -, læs standardind.\n"
#. TRANSLATORS: This message indicates the bug reporting address
#. for this package. Please add _another line_ saying
#. "Report translation bugs to <...>\n" with the email or WWW
#. address for translation bugs. Thanks.
#: src/xz/message.c:1248
#, c-format
msgid "Report bugs to <%s> (in English or Finnish).\n"
msgstr ""
"Rapporter fejl til <%s> (på engelsk eller finsk).\n"
"Rapporter oversættelsesfejl til <dansk@dansk-gruppen.dk>.\n"
#: src/xz/message.c:1250
#, c-format
msgid "%s home page: <%s>\n"
msgstr "%s hjemmeside: <%s>\n"
#: src/xz/message.c:1254
msgid "THIS IS A DEVELOPMENT VERSION NOT INTENDED FOR PRODUCTION USE."
msgstr "DETTE ER EN UDVIKLINGSVERSION - BRUG IKKE I PRODUKTION."
#: src/xz/options.c:86
#, c-format
msgid "%s: Options must be `name=value' pairs separated with commas"
msgstr "%s: Tilvalg skal være »navne=værdi«-par adskilt med kommaer"
#: src/xz/options.c:93
#, c-format
msgid "%s: Invalid option name"
msgstr "%s: Ugyldigt tilvalgsnavn"
#: src/xz/options.c:113
#, c-format
msgid "%s: Invalid option value"
msgstr "%s: Ugyldigt tilvalgsværdi"
#: src/xz/options.c:247
#, c-format
msgid "Unsupported LZMA1/LZMA2 preset: %s"
msgstr "LZMA1/LZMA2-forhåndskonfiguration er ikke understøttet: %s"
#: src/xz/options.c:355
msgid "The sum of lc and lp must not exceed 4"
msgstr "Summen af lc og lp må ikke være højere end 4"
#: src/xz/options.c:359
#, c-format
msgid "The selected match finder requires at least nice=%<PRIu32>"
msgstr "Den valgte matchfinder kræver mindst nice=%<PRIu32>"
#: src/xz/suffix.c:133 src/xz/suffix.c:258
#, c-format
msgid "%s: With --format=raw, --suffix=.SUF is required unless writing to stdout"
msgstr "%s: med --format=raw, --suffix=.SUF er krævet med mindre der skrives til standardud"
#: src/xz/suffix.c:164
#, c-format
msgid "%s: Filename has an unknown suffix, skipping"
msgstr "%s: Filnavn har ukendt endelse, udelader"
#: src/xz/suffix.c:185
#, c-format
msgid "%s: File already has `%s' suffix, skipping"
msgstr "%s: Filen har allrede endelsen »%s«, udelader."
#: src/xz/suffix.c:393
#, c-format
msgid "%s: Invalid filename suffix"
msgstr "%s: Ugyldig filnavnendelse"
#: src/xz/util.c:71
#, c-format
msgid "%s: Value is not a non-negative decimal integer"
msgstr "%s: Værdi er ikke et positivt decimalheltal"
#: src/xz/util.c:113
#, c-format
msgid "%s: Invalid multiplier suffix"
msgstr "%s: Ugyldig multiplikatorendelse"
#: src/xz/util.c:115
msgid "Valid suffixes are `KiB' (2^10), `MiB' (2^20), and `GiB' (2^30)."
msgstr "Gyldige endelser er »KiB« (2^10), »MiB« (2^20) og »GiB« (2^30)."
#: src/xz/util.c:132
#, c-format
msgid "Value of the option `%s' must be in the range [%<PRIu64>, %<PRIu64>]"
msgstr "Værdien for tilvalget »%s« skal være i intervallet [%<PRIu64>, %<PRIu64>]"
#: src/xz/util.c:257
msgid "Empty filename, skipping"
msgstr "Tomt filnavn, udelader"
#: src/xz/util.c:271
msgid "Compressed data cannot be read from a terminal"
msgstr "Komprimerede data kan ikke læses fra en terminal"
#: src/xz/util.c:284
msgid "Compressed data cannot be written to a terminal"
msgstr "Komprimerede data kan ikke skrives til en terminal"
#: src/common/tuklib_exit.c:39
msgid "Writing to standard output failed"
msgstr "Skrivning til standardud mislykkedes"
#: src/common/tuklib_exit.c:42
msgid "Unknown error"
msgstr "Ukendt fejl"

1213
po/de.po

File diff suppressed because it is too large Load Diff

1148
po/eo.po Normal file

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More