Commit Graph

541 Commits

Author SHA1 Message Date
Lasse Collin 4fdcccd85e Add support for AmigaOS/AROS to tuklib_physmem().
Thanks to Fredrik Wikstrom.
2014-12-17 21:15:02 +02:00
Lasse Collin f229fa32bf 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-12-17 21:13:42 +02:00
Lasse Collin 495aaf3a5b Bump version and soname for 5.0.7. 2014-09-20 20:44:32 +03:00
Lasse Collin d1b0276aaf liblzma: Fix invalid Libs.private value in liblzma.pc. 2014-09-20 20:21:18 +03:00
Lasse Collin cac72956b1 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:48:16 +03:00
Lasse Collin 2cdf0875de Bump version and soname for 5.0.6. 2014-09-14 19:35:45 +03:00
Lasse Collin 64228d0d5c 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-09-09 19:18:23 +03:00
Lasse Collin 98d3368ef4 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-26 08:47:36 +03:00
Lasse Collin b9f0584e3e 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-26 08:47:24 +03:00
Lasse Collin cc41bcaf77 xz: Fix a comment. 2014-04-26 08:45:49 +03:00
Lasse Collin e34025d666 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-04-26 08:38:12 +03:00
Lasse Collin 0b6168974f liblzma: Remove a useless C99ism from sha256.c.
Unsurprisingly it makes no difference in compiled output.
2014-04-26 08:38:12 +03:00
Lasse Collin 41e436076c 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-04-26 08:37:15 +03:00
Lasse Collin c33efefd4e Fix typos in comments. 2014-04-26 08:37:00 +03:00
Lasse Collin 05192b32e5 liblzma: Document the need for block->check for lzma_block_header_decode().
Thanks to Tomer Chachamu.
2014-04-26 08:31:43 +03:00
Lasse Collin 090c69dda5 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.
2014-04-26 08:29:17 +03:00
Lasse Collin b69900ed0b 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:03:54 +03:00
Lasse Collin cb94bb6d1f Bump version and soname for 5.0.5. 2013-06-30 15:54:38 +03:00
Lasse Collin b7dee202d5 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:34 +03:00
Lasse Collin 265e7b44d8 xz: Remove an outdated NetBSD-specific comment.
Nowadays errno == EFTYPE is documented in open(2).
2013-06-28 22:04:40 +03:00
Lasse Collin 78c2f8db90 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 22:04:36 +03:00
Lasse Collin 91750dff8f 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 22:04:32 +03:00
Lasse Collin e11888a79a 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:31:19 +03:00
Lasse Collin cb84e27802 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-26 10:59:19 +03:00
Lasse Collin d98ede7d70 xz: Make the man page more friendly to doclifter.
Thanks to Eric S. Raymond.
2013-06-26 10:58:07 +03:00
Lasse Collin 19b447b64b 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-26 10:54:24 +03:00
Lasse Collin 45edf2966f 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-26 10:54:18 +03:00
Lasse Collin b065984e5a xz: Change size_t to uint32_t in a few places. 2013-06-26 10:54:09 +03:00
Lasse Collin efb07cfba6 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-06-26 10:53:57 +03:00
Jeff Bastian ad8282efe4 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:34:42 +03:00
Lasse Collin 9271a3eb0e 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

Conflicts:
	src/liblzma/common/alone_decoder.c
	src/liblzma/common/alone_decoder.h
2013-04-05 19:34:09 +03:00
Lasse Collin 211b931cee 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-04-05 19:28:08 +03:00
Jonathan Nieder 9f62fd9605 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-12-15 20:01:45 +02:00
Lasse Collin 1d05980f5b xz: Fix the note about --rsyncable on the man page. 2012-12-15 20:01:45 +02:00
Lasse Collin fb68497333 xz: Improve handling of failed realloc in xrealloc.
Thanks to Jim Meyering.
2012-12-15 20:01:45 +02:00
Lasse Collin 75013db6d4 A few typo fixes to comments and the xz man page.
Thanks to Jim Meyering.
2012-12-15 20:01:02 +02:00
Lasse Collin 20778053a0 xz: Update man page date to match the latest update. 2012-06-22 14:36:16 +03:00
Lasse Collin 2cefa84af6 Bump version and soname for 5.0.4. 2012-06-22 10:25:43 +03:00
Lasse Collin dd13b66bf5 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-29 12:54:47 +03:00
Lasse Collin 86e57e4bfe xz: Don't show a huge number in -vv when memory limit is disabled. 2012-05-29 12:54:47 +03:00
Lasse Collin 13e44a94da 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-29 12:54:22 +03:00
Lasse Collin 2f90345e13 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-29 12:54:22 +03:00
Lasse Collin 7c3ba2ed5c liblzma: Remove outdated comments. 2012-05-24 19:16:14 +03:00
Lasse Collin b7ad23fa78 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-05-24 18:52:48 +03:00
Lasse Collin d06d32f108 xz: Fix a typo in a comment.
Thanks to Bela Lubkin.
2011-11-04 17:57:45 +02:00
Lasse Collin 55fd02f83e xz: Fix xz on EBCDIC systems.
Thanks to Chris Donawa.
2011-11-03 17:44:22 +02:00
Lasse Collin 70f03b51ff Workaround unusual SIZE_MAX on SCO OpenServer. 2011-09-05 16:05:44 +03:00
Lasse Collin 2c144a0365 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-09-05 16:05:44 +03:00
Lasse Collin 7fcc6334ea liblzma: Remove unneeded semicolon. 2011-06-16 12:16:05 +03:00
Lasse Collin 631f4d3ae6 Don't call close(-1) in tuklib_open_stdxxx() on error.
Thanks to Jim Meyering.
2011-05-28 18:54:42 +03:00