1
0
Fork 0

Merging upstream version 1.5.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-24 05:53:15 +01:00
parent 3a44ca3665
commit 060bb99151
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
30 changed files with 328 additions and 279 deletions

View file

@ -1,3 +1,13 @@
2016-05-15 Antonio Diaz Diaz <antonio@gnu.org>
* Version 1.5 released.
* zupdate.cc (zupdate_file): Pass '-q' to zcmp if verbosity < 0.
* zcat.cc zgrep.cc ztest.cc (main): Don't use stdin more than once.
* zdiff.cc (set_fifonames): Use '_' if both names are different.
* configure: Avoid warning on some shells when testing for g++.
* Makefile.in: Detect the existence of install-info.
* testsuite/check.sh: A POSIX shell is required to run the tests.
2015-05-29 Antonio Diaz Diaz <antonio@gnu.org>
* Version 1.4 released.
@ -105,7 +115,7 @@
* Version 0.3 released.
* Removed default compressor.
* zcat.in, zgrep.in: Do not read data from stdin.
* zcat.in, zgrep.in: Don't read data from stdin.
* Updated home page and mailing list addresses.
2009-08-13 Antonio Diaz Diaz <ant_diaz@teleline.es>
@ -118,7 +128,7 @@
* Version 0.1 released.
Copyright (C) 2009-2015 Antonio Diaz Diaz.
Copyright (C) 2009-2016 Antonio Diaz Diaz.
This file is a collection of facts, and thus it is not copyrightable,
but just in case, you have unlimited permission to copy, distribute and

View file

@ -1,7 +1,7 @@
Requirements
------------
You will need a C++ compiler.
I use gcc 4.9.1 and 4.1.2, but the code should compile with any
I use gcc 5.3.0 and 4.1.2, but the code should compile with any
standards compliant compiler.
Gcc is available at http://gcc.gnu.org.
@ -70,7 +70,7 @@ After running 'configure', you can run 'make' and 'make install' as
explained above.
Copyright (C) 2009-2015 Antonio Diaz Diaz.
Copyright (C) 2009-2016 Antonio Diaz Diaz.
This file is free documentation: you have unlimited permission to copy,
distribute and modify it.

View file

@ -6,6 +6,7 @@ INSTALL_SCRIPT = $(INSTALL) -m 755
INSTALL_DATA = $(INSTALL) -m 644
INSTALL_DIR = $(INSTALL) -d -m 755
SHELL = /bin/sh
CAN_RUN_INSTALLINFO = $(SHELL) -c "install-info --version" > /dev/null 2>&1
objs = arg_parser.o rc.o zutils.o \
zcat.o zcmp.o zdiff.o zgrep.o ztest.o zupdate.o
@ -109,7 +110,7 @@ $(VPATH)/doc/ztest.1 : ztest
-o $@ --no-info ./ztest
$(VPATH)/doc/zupdate.1 : zupdate
help2man -n 'recompress bzip2, gzip, xz files to lzip files' \
help2man -n 'recompress bzip2, gzip, xz files to lzip format' \
-o $@ --no-info ./zupdate
Makefile : $(VPATH)/configure $(VPATH)/Makefile.in
@ -145,7 +146,9 @@ install-info :
if [ ! -d "$(DESTDIR)$(infodir)" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(infodir)" ; fi
-rm -f "$(DESTDIR)$(infodir)/$(pkgname).info"*
$(INSTALL_DATA) $(VPATH)/doc/$(pkgname).info "$(DESTDIR)$(infodir)/$(pkgname).info"
-install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$(pkgname).info"
-if $(CAN_RUN_INSTALLINFO) ; then \
install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$(pkgname).info" ; \
fi
install-info-compress : install-info
lzip -v -9 "$(DESTDIR)$(infodir)/$(pkgname).info"
@ -187,7 +190,9 @@ uninstall-bin :
-rm -f "$(DESTDIR)$(sysconfdir)/$(pkgname)rc"
uninstall-info :
-install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$(pkgname).info"
-if $(CAN_RUN_INSTALLINFO) ; then \
install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$(pkgname).info" ; \
fi
-rm -f "$(DESTDIR)$(infodir)/$(pkgname).info"*
uninstall-man :

17
NEWS
View file

@ -1,14 +1,9 @@
Changes in version 1.4:
Changes in version 1.5:
The option "--format" has been renamed to "-O, --force-format".
zupdate now passes '-q' to zcmp if specified.
Option "-M, --format=<list>" now restricts automatic search to the
formats listed in the comma-separated <list>. This change introduces a
backward incompatibility with previous versions of zutils.
zcat, zgrep and ztest no longer read from standard input more than once
if '-' is specified multiple times.
If the pattern begins with "-", zgrep now prepends "-e" before passing
it to grep. ('zgrep -- -pattern file' now works as expected).
The targets "install-compress", "install-strip-compress",
"install-info-compress" and "install-man-compress" have been added to
the Makefile.
zdiff now uses '_' as separator if both temporary file names are
otherwise different. For example 'xxx_file.lz' and 'xxx_file.gz'.

5
README
View file

@ -12,7 +12,8 @@ those utilities supporting it.
The provided utilities are zcat, zcmp, zdiff, zgrep, ztest and zupdate.
The supported formats are bzip2, gzip, lzip and xz.
The compressor to be used for each format is configurable at runtime.
Zutils uses external compressors. The compressor to be used for each
format is configurable at runtime.
zcat, zcmp, zdiff, and zgrep are improved replacements for the shell
scripts provided by GNU gzip. ztest is unique to zutils. zupdate is
@ -36,7 +37,7 @@ have been compressed. Decompressed is used to refer to data which has
undergone the process of decompression.
Copyright (C) 2009-2015 Antonio Diaz Diaz.
Copyright (C) 2009-2016 Antonio Diaz Diaz.
This file is free documentation: you have unlimited permission to copy,
distribute and modify it.

View file

@ -1,5 +1,5 @@
/* Arg_parser - POSIX/GNU command line argument parser. (C++ version)
Copyright (C) 2006-2015 Antonio Diaz Diaz.
Copyright (C) 2006-2016 Antonio Diaz Diaz.
This library is free software. Redistribution and use in source and
binary forms, with or without modification, are permitted provided

View file

@ -1,5 +1,5 @@
/* Arg_parser - POSIX/GNU command line argument parser. (C++ version)
Copyright (C) 2006-2015 Antonio Diaz Diaz.
Copyright (C) 2006-2016 Antonio Diaz Diaz.
This library is free software. Redistribution and use in source and
binary forms, with or without modification, are permitted provided

14
configure vendored
View file

@ -1,12 +1,12 @@
#! /bin/sh
# configure script for Zutils - Utilities dealing with compressed files
# Copyright (C) 2009-2015 Antonio Diaz Diaz.
# Copyright (C) 2009-2016 Antonio Diaz Diaz.
#
# This configure script is free software: you have unlimited permission
# to copy, distribute and modify it.
pkgname=zutils
pkgversion=1.4
pkgversion=1.5
srctrigger=doc/${pkgname}.texi
# clear some things potentially inherited from environment.
@ -28,8 +28,8 @@ DIFF=diff
GREP=grep
# checking whether we are using GNU C++.
${CXX} --version > /dev/null 2>&1
if [ $? != 0 ] ; then
if /bin/sh -c "${CXX} --version" > /dev/null 2>&1 ; then true
else
CXX=c++
CXXFLAGS='-W -O2'
fi
@ -148,7 +148,7 @@ if [ -z "${no_create}" ] ; then
rm -f config.status
cat > config.status << EOF
#! /bin/sh
# This file was generated automatically by configure. Do not edit.
# This file was generated automatically by configure. Don't edit.
# Run this file to recreate the current configuration.
#
# This script is free software: you have unlimited permission
@ -177,8 +177,8 @@ echo "GREP = ${GREP}"
rm -f Makefile
cat > Makefile << EOF
# Makefile for Zutils - Utilities dealing with compressed files
# Copyright (C) 2009-2015 Antonio Diaz Diaz.
# This file was generated automatically by configure. Do not edit.
# Copyright (C) 2009-2016 Antonio Diaz Diaz.
# This file was generated automatically by configure. Don't edit.
#
# This Makefile is free software: you have unlimited permission
# to copy, distribute and modify it.

View file

@ -1,19 +1,20 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.46.1.
.TH ZCAT "1" "May 2015" "zcat (zutils) 1.4" "User Commands"
.TH ZCAT "1" "May 2016" "zcat (zutils) 1.5" "User Commands"
.SH NAME
zcat \- decompress and concatenate files to standard output
.SH SYNOPSIS
.B zcat
[\fI\,options\/\fR] [\fI\,files\/\fR]
.SH DESCRIPTION
Zcat copies each given file ("\-" means standard input), to standard
output. If any given file is compressed, its decompressed content is
used. If a given file does not exist, and its name does not end with one
of the known extensions, zcat tries the compressed file names
corresponding to the supported formats. If no files are specified,
data is read from standard input, decompressed if needed, and sent to
standard output. Data read from standard input must be of the same type;
all uncompressed or all in the same compression format.
Zcat copies each given file to standard output. If any given file is
compressed, its decompressed content is used. If a given file does not
exist, and its name does not end with one of the known extensions, zcat
tries the compressed file names corresponding to the supported formats.
.PP
If no files are specified, or if a file is specified as '\-', data is
read from standard input, decompressed if needed, and sent to standard
output. Data read from standard input must be of the same type; all
uncompressed or all in the same compression format.
.PP
The supported formats are bzip2, gzip, lzip and xz.
.PP
@ -87,7 +88,7 @@ Report bugs to zutils\-bug@nongnu.org
.br
Zutils home page: http://www.nongnu.org/zutils/zutils.html
.SH COPYRIGHT
Copyright \(co 2015 Antonio Diaz Diaz.
Copyright \(co 2016 Antonio Diaz Diaz.
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>
.br
This is free software: you are free to change and redistribute it.

View file

@ -1,16 +1,16 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.46.1.
.TH ZCMP "1" "May 2015" "zcmp (zutils) 1.4" "User Commands"
.TH ZCMP "1" "May 2016" "zcmp (zutils) 1.5" "User Commands"
.SH NAME
zcmp \- decompress and compare two files byte by byte
.SH SYNOPSIS
.B zcmp
[\fI\,options\/\fR] \fI\,file1 \/\fR[\fI\,file2\/\fR]
.SH DESCRIPTION
Zcmp compares two files ("\-" means standard input), and if they
differ, tells the first byte and line number where they differ. Bytes
and lines are numbered starting with 1. If any given file is compressed,
its decompressed content is used. Compressed files are decompressed on
the fly; no temporary files are created.
Zcmp compares two files ('\-' means standard input), and if they differ,
tells the first byte and line number where they differ. Bytes and lines
are numbered starting with 1. If any given file is compressed, its
decompressed content is used. Compressed files are decompressed on the
fly; no temporary files are created.
.PP
The supported formats are bzip2, gzip, lzip and xz.
.PP
@ -85,7 +85,7 @@ Report bugs to zutils\-bug@nongnu.org
.br
Zutils home page: http://www.nongnu.org/zutils/zutils.html
.SH COPYRIGHT
Copyright \(co 2015 Antonio Diaz Diaz.
Copyright \(co 2016 Antonio Diaz Diaz.
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>
.br
This is free software: you are free to change and redistribute it.

View file

@ -1,12 +1,12 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.46.1.
.TH ZDIFF "1" "May 2015" "zdiff (zutils) 1.4" "User Commands"
.TH ZDIFF "1" "May 2016" "zdiff (zutils) 1.5" "User Commands"
.SH NAME
zdiff \- decompress and compare two files line by line
.SH SYNOPSIS
.B zdiff
[\fI\,options\/\fR] \fI\,file1 \/\fR[\fI\,file2\/\fR]
.SH DESCRIPTION
Zdiff compares two files ("\-" means standard input), and if they
Zdiff compares two files ('\-' means standard input), and if they
differ, shows the differences line by line. If any given file is
compressed, its decompressed content is used. Zdiff is a front end to
the diff program and has the limitation that messages from diff refer to
@ -109,7 +109,7 @@ Report bugs to zutils\-bug@nongnu.org
.br
Zutils home page: http://www.nongnu.org/zutils/zutils.html
.SH COPYRIGHT
Copyright \(co 2015 Antonio Diaz Diaz.
Copyright \(co 2016 Antonio Diaz Diaz.
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>
.br
This is free software: you are free to change and redistribute it.

View file

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.46.1.
.TH ZGREP "1" "May 2015" "zgrep (zutils) 1.4" "User Commands"
.TH ZGREP "1" "May 2016" "zgrep (zutils) 1.5" "User Commands"
.SH NAME
zgrep \- search compressed files for a regular expression
.SH SYNOPSIS
@ -11,10 +11,12 @@ on any combination of compressed and uncompressed files. If any given
file is compressed, its decompressed content is used. If a given file
does not exist, and its name does not end with one of the known
extensions, zgrep tries the compressed file names corresponding to the
supported formats. If no files are specified, data is read from
standard input, decompressed if needed, and fed to grep. Data read from
standard input must be of the same type; all uncompressed or all
in the same compression format.
supported formats.
.PP
If no files are specified, or if a file is specified as '\-', data is
read from standard input, decompressed if needed, and fed to grep. Data
read from standard input must be of the same type; all uncompressed or
all in the same compression format.
.PP
The supported formats are bzip2, gzip, lzip and xz.
.PP
@ -133,7 +135,7 @@ Report bugs to zutils\-bug@nongnu.org
.br
Zutils home page: http://www.nongnu.org/zutils/zutils.html
.SH COPYRIGHT
Copyright \(co 2015 Antonio Diaz Diaz.
Copyright \(co 2016 Antonio Diaz Diaz.
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>
.br
This is free software: you are free to change and redistribute it.

View file

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.46.1.
.TH ZTEST "1" "May 2015" "ztest (zutils) 1.4" "User Commands"
.TH ZTEST "1" "May 2016" "ztest (zutils) 1.5" "User Commands"
.SH NAME
ztest \- verify integrity of compressed files
.SH SYNOPSIS
@ -7,9 +7,10 @@ ztest \- verify integrity of compressed files
[\fI\,options\/\fR] [\fI\,files\/\fR]
.SH DESCRIPTION
Ztest verifies the integrity of the specified compressed files.
Uncompressed files are ignored. If no files are specified, the integrity
of compressed data read from standard input is verified. Data read from
standard input must be all in the same compression format.
Uncompressed files are ignored. If no files are specified, or if a file
is specified as '\-', the integrity of compressed data read from standard
input is verified. Data read from standard input must be all in the same
compression format.
.PP
The supported formats are bzip2, gzip, lzip and xz.
.PP
@ -61,7 +62,7 @@ Report bugs to zutils\-bug@nongnu.org
.br
Zutils home page: http://www.nongnu.org/zutils/zutils.html
.SH COPYRIGHT
Copyright \(co 2015 Antonio Diaz Diaz.
Copyright \(co 2016 Antonio Diaz Diaz.
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>
.br
This is free software: you are free to change and redistribute it.

View file

@ -1,7 +1,7 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.46.1.
.TH ZUPDATE "1" "May 2015" "zupdate (zutils) 1.4" "User Commands"
.TH ZUPDATE "1" "May 2016" "zupdate (zutils) 1.5" "User Commands"
.SH NAME
zupdate \- recompress bzip2, gzip, xz files to lzip files
zupdate \- recompress bzip2, gzip, xz files to lzip format
.SH SYNOPSIS
.B zupdate
[\fI\,options\/\fR] [\fI\,files\/\fR]
@ -34,7 +34,7 @@ display this help and exit
output version information and exit
.TP
\fB\-f\fR, \fB\-\-force\fR
do not skip a file even if the .lz exists
don't skip a file even if the .lz exists
.TP
\fB\-k\fR, \fB\-\-keep\fR
keep (don't delete) input files
@ -76,7 +76,7 @@ Report bugs to zutils\-bug@nongnu.org
.br
Zutils home page: http://www.nongnu.org/zutils/zutils.html
.SH COPYRIGHT
Copyright \(co 2015 Antonio Diaz Diaz.
Copyright \(co 2016 Antonio Diaz Diaz.
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>
.br
This is free software: you are free to change and redistribute it.

View file

@ -12,7 +12,7 @@ File: zutils.info, Node: Top, Next: Introduction, Up: (dir)
Zutils Manual
*************
This manual is for Zutils (version 1.4, 29 May 2015).
This manual is for Zutils (version 1.5, 15 May 2016).
* Menu:
@ -29,7 +29,7 @@ This manual is for Zutils (version 1.4, 29 May 2015).
* Concept index:: Index of concepts
Copyright (C) 2009-2015 Antonio Diaz Diaz.
Copyright (C) 2009-2016 Antonio Diaz Diaz.
This manual is free documentation: you have unlimited permission to
copy, distribute and modify it.
@ -52,7 +52,8 @@ in those utilities supporting it.
The provided utilities are zcat, zcmp, zdiff, zgrep, ztest and zupdate.
The supported formats are bzip2, gzip, lzip and xz.
The compressor to be used for each format is configurable at runtime.
Zutils uses external compressors. The compressor to be used for each
format is configurable at runtime.
zcat, zcmp, zdiff, and zgrep are improved replacements for the shell
scripts provided by GNU gzip. ztest is unique to zutils. zupdate is
@ -140,7 +141,7 @@ described here.
'--lz=COMMAND'
'--xz=COMMAND'
Set program (may include arguments) to be used as (de)compressor
for the given format. The mane of the program can't begin with
for the given format. The name of the program can't begin with
'-'. These options override the values set in 'zutilsrc'. The
compression program used must meet three requirements:
@ -163,7 +164,7 @@ File: zutils.info, Node: The zutilsrc file, Next: Zcat, Prev: Common options,
'zutilsrc' is the runtime configuration file for zutils. In it you may
define the compressor name and options to be used for each format. The
'zutilsrc' file is optional; you do not need to install it in order to
'zutilsrc' file is optional; you don't need to install it in order to
run zutils.
The compressors specified in the command line override those
@ -186,16 +187,15 @@ File: zutils.info, Node: Zcat, Next: Zcmp, Prev: The zutilsrc file, Up: Top
4 Zcat
******
zcat copies each given file ('-' means standard input), to standard
output. If any given file is compressed, its decompressed content is
used. If a given file does not exist, and its name does not end with one
of the known extensions, zcat tries the compressed file names
corresponding to the supported formats.
zcat copies each given file to standard output. If any given file is
compressed, its decompressed content is used. If a given file does not
exist, and its name does not end with one of the known extensions, zcat
tries the compressed file names corresponding to the supported formats.
If no files are specified, data is read from standard input,
decompressed if needed, and sent to standard output. Data read from
standard input must be of the same type; all uncompressed or all in the
same compression format.
If no files are specified, or if a file is specified as '-', data is
read from standard input, decompressed if needed, and sent to standard
output. Data read from standard input must be of the same type; all
uncompressed or all in the same compression format.
The format for running zcat is:
@ -336,7 +336,7 @@ differences were found, and 2 means trouble.
'-s'
'--quiet'
'--silent'
Do not print anything; only return an exit status indicating
Don't print anything; only return an exit status indicating
whether the files differ.
@ -460,10 +460,10 @@ does not exist, and its name does not end with one of the known
extensions, zgrep tries the compressed file names corresponding to the
supported formats.
If no files are specified, data is read from standard input,
decompressed if needed, and fed to grep. Data read from standard input
must be of the same type; all uncompressed or all in the same
compression format.
If no files are specified, or if a file is specified as '-', data is
read from standard input, decompressed if needed, and fed to grep.
Data read from standard input must be of the same type; all uncompressed
or all in the same compression format.
The format for running zgrep is:
@ -509,6 +509,9 @@ matches were found, and 2 means trouble.
'-f FILE'
'--file=FILE'
Obtain patterns from FILE, one per line.
When searching in several files at once, command substitution can
be used with '-e' to read FILE only once, for example if FILE is
not a regular file: 'zgrep -e "$(cat FILE)" file1.lz file2.gz'
'-F'
'--fixed-strings'
@ -594,9 +597,10 @@ File: zutils.info, Node: Ztest, Next: Zupdate, Prev: Zgrep, Up: Top
*******
ztest verifies the integrity of the specified compressed files.
Uncompressed files are ignored. If no files are specified, the integrity
of compressed data read from standard input is verified. Data read from
standard input must be all in the same compression format.
Uncompressed files are ignored. If no files are specified, or if a file
is specified as '-', the integrity of compressed data read from
standard input is verified. Data read from standard input must be all in
the same compression format.
Note that some xz files lack integrity information, and therefore
can't be verified as reliably as the other formats can.
@ -642,7 +646,7 @@ File: zutils.info, Node: Zupdate, Next: Problems, Prev: Ztest, Up: Top
*********
zupdate recompresses files from bzip2, gzip, and xz formats to lzip
format. The originals are compared with the new files and then deleted.
format. Each original is compared with the new file and then deleted.
Only regular files with standard file name extensions are recompressed,
other files are ignored. Compressed files are decompressed and then
recompressed on the fly; no temporary files are created. The lzip format
@ -682,7 +686,7 @@ otherwise.
'-f'
'--force'
Do not skip a file for which a lzip compressed version already
Don't skip a file for which a lzip compressed version already
exists. '--force' compares the content of the input file with the
content of the existing lzip file and deletes the input file if
both contents are identical.
@ -758,17 +762,17 @@ Concept index
Tag Table:
Node: Top222
Node: Introduction1142
Node: Common options3692
Ref: compressor-requirements5450
Node: The zutilsrc file5822
Node: Zcat6748
Node: Zcmp8795
Node: Zdiff11255
Node: Zgrep13895
Node: Ztest16990
Node: Zupdate18494
Node: Problems21369
Node: Concept index21903
Node: Common options3726
Ref: compressor-requirements5484
Node: The zutilsrc file5856
Node: Zcat6781
Node: Zcmp8834
Node: Zdiff11293
Node: Zgrep13933
Node: Ztest17271
Node: Zupdate18809
Node: Problems21681
Node: Concept index22215

End Tag Table

View file

@ -6,8 +6,8 @@
@finalout
@c %**end of header
@set UPDATED 29 May 2015
@set VERSION 1.4
@set UPDATED 15 May 2016
@set VERSION 1.5
@dircategory Data Compression
@direntry
@ -49,7 +49,7 @@ This manual is for Zutils (version @value{VERSION}, @value{UPDATED}).
@end menu
@sp 1
Copyright @copyright{} 2009-2015 Antonio Diaz Diaz.
Copyright @copyright{} 2009-2016 Antonio Diaz Diaz.
This manual is free documentation: you have unlimited permission
to copy, distribute and modify it.
@ -72,7 +72,8 @@ in those utilities supporting it.
@noindent
The provided utilities are zcat, zcmp, zdiff, zgrep, ztest and zupdate.@*
The supported formats are bzip2, gzip, lzip and xz.@*
The compressor to be used for each format is configurable at runtime.
Zutils uses external compressors. The compressor to be used for each
format is configurable at runtime.
zcat, zcmp, zdiff, and zgrep are improved replacements for the shell
scripts provided by GNU gzip. ztest is unique to zutils. zupdate is
@ -164,7 +165,7 @@ Don't read the runtime configuration file @samp{zutilsrc}.
@itemx --lz=@var{command}
@itemx --xz=@var{command}
Set program (may include arguments) to be used as (de)compressor for the
given format. The mane of the program can't begin with @samp{-}. These
given format. The name of the program can't begin with @samp{-}. These
options override the values set in @file{zutilsrc}. The compression
program used must meet three requirements:
@ -189,7 +190,7 @@ It must return 0 if no errors occurred, and a non-zero value otherwise.
@file{zutilsrc} is the runtime configuration file for zutils. In it you
may define the compressor name and options to be used for each format.
The @file{zutilsrc} file is optional; you do not need to install it in
The @file{zutilsrc} file is optional; you don't need to install it in
order to run zutils.
The compressors specified in the command line override those specified
@ -217,16 +218,15 @@ where <format> is one of @samp{bz2}, @samp{gz}, @samp{lz} or @samp{xz}.
@chapter Zcat
@cindex zcat
zcat copies each given file (@samp{-} means standard input), to standard
output. If any given file is compressed, its decompressed content is
used. If a given file does not exist, and its name does not end with one
of the known extensions, zcat tries the compressed file names
corresponding to the supported formats.
zcat copies each given file to standard output. If any given file is
compressed, its decompressed content is used. If a given file does not
exist, and its name does not end with one of the known extensions, zcat
tries the compressed file names corresponding to the supported formats.
If no files are specified, data is read from standard input,
decompressed if needed, and sent to standard output. Data read from
standard input must be of the same type; all uncompressed or all in the
same compression format.
If no files are specified, or if a file is specified as @samp{-}, data
is read from standard input, decompressed if needed, and sent to
standard output. Data read from standard input must be of the same type;
all uncompressed or all in the same compression format.
The format for running zcat is:
@ -378,7 +378,7 @@ without verifying its format, and the exact file names of both
@itemx -s
@itemx --quiet
@itemx --silent
Do not print anything; only return an exit status indicating whether the
Don't print anything; only return an exit status indicating whether the
files differ.
@end table
@ -510,10 +510,10 @@ does not exist, and its name does not end with one of the known
extensions, zgrep tries the compressed file names corresponding to the
supported formats.
If no files are specified, data is read from standard input,
decompressed if needed, and fed to grep. Data read from standard input
must be of the same type; all uncompressed or all in the same
compression format.
If no files are specified, or if a file is specified as @samp{-}, data
is read from standard input, decompressed if needed, and fed to grep.
Data read from standard input must be of the same type; all uncompressed
or all in the same compression format.
The format for running zgrep is:
@ -562,7 +562,11 @@ Treat @var{pattern} as an extended regular expression.
@item -f @var{file}
@itemx --file=@var{file}
Obtain patterns from @var{file}, one per line.
Obtain patterns from @var{file}, one per line.@*
When searching in several files at once, command substitution can be
used with @code{-e} to read @var{file} only once, for example if
@var{file} is not a regular file:
@w{@code{zgrep -e "$(cat @var{file})" file1.lz file2.gz}}
@item -F
@itemx --fixed-strings
@ -648,9 +652,10 @@ Match only whole lines.
@cindex ztest
ztest verifies the integrity of the specified compressed files.
Uncompressed files are ignored. If no files are specified, the integrity
of compressed data read from standard input is verified. Data read from
standard input must be all in the same compression format.
Uncompressed files are ignored. If no files are specified, or if a file
is specified as @samp{-}, the integrity of compressed data read from
standard input is verified. Data read from standard input must be all in
the same compression format.
Note that some xz files lack integrity information, and therefore can't
be verified as reliably as the other formats can.
@ -700,7 +705,7 @@ Further -v's increase the verbosity level.
@cindex zupdate
zupdate recompresses files from bzip2, gzip, and xz formats to lzip
format. The originals are compared with the new files and then deleted.
format. Each original is compared with the new file and then deleted.
Only regular files with standard file name extensions are recompressed,
other files are ignored. Compressed files are decompressed and then
recompressed on the fly; no temporary files are created. The lzip format
@ -745,7 +750,7 @@ zupdate supports the following options:
@table @code
@item -f
@itemx --force
Do not skip a file for which a lzip compressed version already exists.
Don't skip a file for which a lzip compressed version already exists.
@samp{--force} compares the content of the input file with the content
of the existing lzip file and deletes the input file if both contents
are identical.

35
rc.cc
View file

@ -1,5 +1,5 @@
/* Zutils - Utilities dealing with compressed files
Copyright (C) 2009-2015 Antonio Diaz Diaz.
Copyright (C) 2009-2016 Antonio Diaz Diaz.
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
@ -37,7 +37,7 @@ int verbosity = 0;
namespace {
const char * const config_file_name = "zutilsrc";
const char * const program_year = "2015";
const char * const program_year = "2016";
std::string compressor_names[num_formats] =
{ "bzip2", "gzip", "lzip", "xz" }; // default compressor names
@ -173,7 +173,7 @@ bool parse_rc_line( const std::string & line,
while( i < len && std::isspace( line[i] ) ) ++i; // strip spaces
if( i <= 0 || i >= len || line[i] != '=' )
{ if( verbosity >= 0 )
std::fprintf( stderr, "%s %d: missing '='.\n", filename, linenum );
std::fprintf( stderr, "%s %d: missing '='\n", filename, linenum );
return false; }
++i; // skip the '='
if( !parse_compressor_command( line, i, format_index ) )
@ -334,26 +334,23 @@ void show_version()
void show_error( const char * const msg, const int errcode, const bool help )
{
if( verbosity >= 0 )
if( verbosity < 0 ) return;
if( msg && msg[0] )
{
if( msg && msg[0] )
{
std::fprintf( stderr, "%s: %s", program_name, msg );
if( errcode > 0 )
std::fprintf( stderr, ": %s.", std::strerror( errcode ) );
std::fprintf( stderr, "\n" );
}
if( help )
std::fprintf( stderr, "Try '%s --help' for more information.\n",
invocation_name );
std::fprintf( stderr, "%s: %s", program_name, msg );
if( errcode > 0 ) std::fprintf( stderr, ": %s", std::strerror( errcode ) );
std::fputc( '\n', stderr );
}
if( help )
std::fprintf( stderr, "Try '%s --help' for more information.\n",
invocation_name );
}
void show_error2( const char * const msg, const char * const name )
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: %s '%s': %s.\n",
std::fprintf( stderr, "%s: %s '%s': %s\n",
program_name, msg, name, std::strerror( errno ) );
}
@ -369,7 +366,7 @@ void internal_error( const char * const msg )
void show_close_error( const char * const prog_name )
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Can't close output of %s: %s.\n",
std::fprintf( stderr, "%s: Can't close output of %s: %s\n",
program_name, prog_name, std::strerror( errno ) );
}
@ -377,7 +374,7 @@ void show_close_error( const char * const prog_name )
void show_exec_error( const char * const prog_name )
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Can't exec '%s': %s.\n",
std::fprintf( stderr, "%s: Can't exec '%s': %s\n",
program_name, prog_name, std::strerror( errno ) );
}
@ -385,7 +382,7 @@ void show_exec_error( const char * const prog_name )
void show_fork_error( const char * const prog_name )
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Can't fork '%s': %s.\n",
std::fprintf( stderr, "%s: Can't fork '%s': %s\n",
program_name, prog_name, std::strerror( errno ) );
}
@ -399,7 +396,7 @@ int wait_for_child( const pid_t pid, const char * const name,
if( errno != EINTR )
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Error waiting termination of '%s': %s.\n",
std::fprintf( stderr, "%s: Error waiting termination of '%s': %s\n",
program_name, name, std::strerror( errno ) );
_exit( eretval );
}

2
rc.h
View file

@ -1,5 +1,5 @@
/* Zutils - Utilities dealing with compressed files
Copyright (C) 2009-2015 Antonio Diaz Diaz.
Copyright (C) 2009-2016 Antonio Diaz Diaz.
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

View file

@ -1,5 +1,5 @@
/* Zutils - Utilities dealing with compressed files
Copyright (C) 2009-2015 Antonio Diaz Diaz.
Copyright (C) 2009-2016 Antonio Diaz Diaz.
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

View file

@ -1,6 +1,6 @@
#! /bin/sh
# check script for Zutils - Utilities dealing with compressed files
# Copyright (C) 2009-2015 Antonio Diaz Diaz.
# Copyright (C) 2009-2016 Antonio Diaz Diaz.
#
# This script is free software: you have unlimited permission
# to copy, distribute and modify it.
@ -27,9 +27,16 @@ if [ ! -f "${ZUPDATE}" ] || [ ! -x "${ZUPDATE}" ] ; then
exit 1
fi
if [ -e "${ZUPDATE}" ] 2> /dev/null ; then true
else
echo "$0: a POSIX shell is required to run the tests"
echo "Try bash -c \"$0 $1 $2\""
exit 1
fi
if [ -d tmp ] ; then rm -rf tmp ; fi
mkdir tmp
cd "${objdir}"/tmp
cd "${objdir}"/tmp || framework_failure
for i in ${compressors}; do
cat "${testdir}"/test.txt > in || framework_failure
@ -75,6 +82,9 @@ printf .
"${ZCAT}" -N < in.lz > copy || fail=1
cmp in copy || fail=1
printf .
"${ZCAT}" -N -O lz - - < in.lz > copy || fail=1
cmp in copy || fail=1
printf .
"${ZCAT}" -N --lz='lzip -q' < in.lz > copy || fail=1
cmp in copy || fail=1
printf .
@ -87,25 +97,23 @@ printf .
"${ZCAT}" -N in in.gz in.bz2 in.lz -- -in- -in-.lz > copy || fail=1
cmp in6 copy || fail=1
printf .
"${ZCAT}" -N --format= in.lz 2> /dev/null
"${ZCAT}" -Nq --format=, in.lz
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZCAT}" -N --format=, in.lz 2> /dev/null
"${ZCAT}" -Nq --format=,lz in.lz
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZCAT}" -N --format=,lz in.lz 2> /dev/null
"${ZCAT}" -Nq --format=gz,,lz in.lz
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZCAT}" -N --format=gz,,lz in.lz 2> /dev/null
"${ZCAT}" -Nq --format=lz,, in.lz
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZCAT}" -N --format=lz,, in.lz 2> /dev/null
"${ZCAT}" -Nq --format=nc in.lz
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZCAT}" -N --format=nc in.lz 2> /dev/null
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZCAT}" -N --lz='-lzip -q' in.lz 2> /dev/null
"${ZCAT}" -Nq --lz='-lzip -q' in.lz
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZCAT}" -N --force-format=gz in.bz2 2> /dev/null
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZCAT}" -N --force-format=bz2 in.lz 2> /dev/null
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZCAT}" -N --force-format=lz in.gz 2> /dev/null
"${ZCAT}" -Nq --force-format=lz in.gz
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZCAT}" -N --bad-option 2> /dev/null
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
@ -130,16 +138,16 @@ for i in ${extensions}; do
printf .
done
"${ZCMP}" -N in in6 2> /dev/null
"${ZCMP}" -Nq in in6
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZCMP}" -N -n 0 in in6 || fail=1
"${ZCMP}" -N -n 100 in in6 || fail=1
"${ZCMP}" -N -n 1000 in in6 || fail=1
"${ZCMP}" -N -n 10000 in in6 || fail=1
printf .
"${ZCMP}" -N in.tar pin.tar > /dev/null
"${ZCMP}" -Nq in.tar pin.tar
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZCMP}" -N -i 0,11 in.tar pin.tar 2> /dev/null
"${ZCMP}" -Nq -i 0,11 in.tar pin.tar
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZCMP}" -N -i 0,11 -n 0 in.tar pin.tar || fail=1
"${ZCMP}" -N -i 0,11 -n 100 in.tar pin.tar || fail=1
@ -184,10 +192,10 @@ printf .
printf .
"${ZCMP}" -N -q --force-format=lz in.lz
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZCMP}" -N --force-format=lz in.gz in.lz 2> /dev/null
"${ZCMP}" -Nq --force-format=lz in.gz in.lz
r=$?
if [ $r = 1 ] || [ $r = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZCMP}" -N -n -1 in in 2> /dev/null
"${ZCMP}" -Nq -n -1 in in
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZCMP}" -N --bad-option in in 2> /dev/null
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
@ -263,17 +271,17 @@ if [ $r = 1 ] || [ $r = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
mkdir tmp2
cat in > tmp2/x || framework_failure
cat in.lz > tmp2/x.lz || framework_failure
"${ZDIFF}" -N --format=bz2 tmp2/x < /dev/null > /dev/null
cat in > tmp2/a || framework_failure
cat in.lz > tmp2/a.lz || framework_failure
"${ZDIFF}" -N --format=bz2 tmp2/a < /dev/null > /dev/null
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZDIFF}" -N --format=gz tmp2/x < /dev/null > /dev/null
"${ZDIFF}" -N --format=gz tmp2/a < /dev/null > /dev/null
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZDIFF}" -N --format=lz tmp2/x.lz < /dev/null > /dev/null
"${ZDIFF}" -N --format=lz tmp2/a.lz < /dev/null > /dev/null
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZDIFF}" -N --format=lz tmp2/x < /dev/null
"${ZDIFF}" -N --format=lz tmp2/a < /dev/null
if [ $? = 0 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZDIFF}" -N --format=un tmp2/x.lz < /dev/null
"${ZDIFF}" -N --format=un tmp2/a.lz < /dev/null
if [ $? = 0 ] ; then printf . ; else printf - ; fail=1 ; fi
rm -r tmp2 || framework_failure
@ -303,7 +311,7 @@ for i in ${extensions}; do
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
done
"${ZGREP}" -N "GNU" pin.tar > /dev/null || fail=1
"${ZGREP}" -N pin.tar -e "GNU" > /dev/null || fail=1
printf .
"${ZGREP}" -N "GNU" < pin.tar > /dev/null || fail=1
printf .
@ -311,11 +319,13 @@ printf .
printf .
"${ZGREP}" -N "nx_pattern" -r . in > /dev/null
if [ $? != 0 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZGREP}" -N "GNU" in > /dev/null || fail=1
"${ZGREP}" -N -e "GNU" in > /dev/null || fail=1
printf .
"${ZGREP}" -N "GNU" < in > /dev/null || fail=1
printf .
"${ZGREP}" -N "GNU" --lz='lzip -q' < in.lz > /dev/null || fail=1
"${ZGREP}" -N -O lz "nx_pattern" - - < in.lz > /dev/null
if [ $? != 0 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZGREP}" -N -e "-free" --lz='lzip -q' < in.lz > /dev/null || fail=1
printf .
"${ZGREP}" -N -- "-free" -in- > /dev/null || fail=1
printf .
@ -363,15 +373,17 @@ printf .
printf .
"${ZTEST}" -N < in.lz || fail=1
printf .
"${ZTEST}" -N - in.gz - < in.lz || fail=1
printf .
"${ZTEST}" -N --lz='lzip -q' < in.lz || fail=1
printf .
"${ZTEST}" -N -r . || fail=1
printf .
"${ZTEST}" -N < in 2> /dev/null
"${ZTEST}" -Nq < in
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
dd if=in.lz bs=1000 count=1 2> /dev/null | "${ZTEST}" -N -q
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZTEST}" -N --force-format=lz in.bz2 2> /dev/null
"${ZTEST}" -Nq --force-format=lz in.bz2
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZTEST}" -N --lz='lzip --bad-option' in.lz 2> /dev/null
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
@ -381,86 +393,86 @@ if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
printf "\ntesting zupdate-%s..." "$2"
cat in.bz2 > x.bz2 || framework_failure
cat in.gz > x.gz || framework_failure
"${ZUPDATE}" -N --bz2=bad_command x.bz2 2> /dev/null
cat in.bz2 > a.bz2 || framework_failure
cat in.gz > a.gz || framework_failure
"${ZUPDATE}" -Nq --bz2=bad_command a.bz2
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZUPDATE}" -N --bz2='bzip2 --bad-option' x.bz2 > /dev/null 2>&1
"${ZUPDATE}" -N --bz2='bzip2 --bad-option' a.bz2 > /dev/null 2>&1
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZUPDATE}" -N --gz=bad_command x.gz 2> /dev/null
"${ZUPDATE}" -Nq --gz=bad_command a.gz
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZUPDATE}" -N --gz='gzip --bad-option' x.gz 2> /dev/null
"${ZUPDATE}" -N --gz='gzip --bad-option' a.gz 2> /dev/null
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZUPDATE}" -N --lz=bad_command x.gz 2> /dev/null
"${ZUPDATE}" -Nq --lz=bad_command a.gz
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZUPDATE}" -N --lz='lzip --bad-option' x.gz 2> /dev/null
"${ZUPDATE}" -N --lz='lzip --bad-option' a.gz 2> /dev/null
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${ZUPDATE}" -N --bad-option 2> /dev/null
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
cat in.lz in.lz > x.lz || framework_failure
"${ZUPDATE}" -N -f x.bz2 x.gz 2> /dev/null
if [ $? = 1 ] && [ -e x.bz2 ] && [ -e x.gz ] && [ -e x.lz ] ; then printf .
cat in.lz in.lz > a.lz || framework_failure
"${ZUPDATE}" -Nq -f a.bz2 a.gz
if [ $? = 1 ] && [ -e a.bz2 ] && [ -e a.gz ] && [ -e a.lz ] ; then printf .
else printf - ; fail=1
fi
rm -f x.lz || framework_failure
rm -f a.lz || framework_failure
"${ZUPDATE}" -N x.bz2
if [ $? = 0 ] && [ ! -e x.bz2 ] && [ -e x.gz ] && [ -e x.lz ] ; then printf .
"${ZUPDATE}" -N a.bz2
if [ $? = 0 ] && [ ! -e a.bz2 ] && [ -e a.gz ] && [ -e a.lz ] ; then printf .
else printf - ; fail=1
fi
rm -f x.lz || framework_failure
"${ZUPDATE}" -N x.gz
if [ $? = 0 ] && [ ! -e x.bz2 ] && [ ! -e x.gz ] && [ -e x.lz ] ; then printf .
rm -f a.lz || framework_failure
"${ZUPDATE}" -N a.gz
if [ $? = 0 ] && [ ! -e a.bz2 ] && [ ! -e a.gz ] && [ -e a.lz ] ; then printf .
else printf - ; fail=1
fi
rm -f x.lz || framework_failure
rm -f a.lz || framework_failure
cat in.bz2 > x.bz2 || framework_failure
cat in.gz > x.gz || framework_failure
"${ZUPDATE}" -N x.bz2 x.gz 2> /dev/null
if [ $? = 1 ] && [ ! -e x.bz2 ] && [ -e x.gz ] && [ -e x.lz ] ; then printf .
cat in.bz2 > a.bz2 || framework_failure
cat in.gz > a.gz || framework_failure
"${ZUPDATE}" -Nq a.bz2 a.gz
if [ $? = 1 ] && [ ! -e a.bz2 ] && [ -e a.gz ] && [ -e a.lz ] ; then printf .
else printf - ; fail=1
fi
rm -f x.lz || framework_failure
rm -f a.lz || framework_failure
cat in.bz2 > x.bz2 || framework_failure
cat in.gz > x.gz || framework_failure
"${ZUPDATE}" -N -f -k x.bz2 x.gz
if [ $? = 0 ] && [ -e x.bz2 ] && [ -e x.gz ] && [ -e x.lz ] ; then printf .
cat in.bz2 > a.bz2 || framework_failure
cat in.gz > a.gz || framework_failure
"${ZUPDATE}" -N -f -k a.bz2 a.gz
if [ $? = 0 ] && [ -e a.bz2 ] && [ -e a.gz ] && [ -e a.lz ] ; then printf .
else printf - ; fail=1
fi
rm -f x.lz || framework_failure
rm -f a.lz || framework_failure
cat in.bz2 > x.bz2 || framework_failure
cat in.gz > x.gz || framework_failure
"${ZUPDATE}" -N -f x.bz2 x.gz
if [ $? = 0 ] && [ ! -e x.bz2 ] && [ ! -e x.gz ] &&
[ ! -e x ] && [ -e x.lz ] ; then printf .
cat in.bz2 > a.bz2 || framework_failure
cat in.gz > a.gz || framework_failure
"${ZUPDATE}" -N -f a.bz2 a.gz
if [ $? = 0 ] && [ ! -e a.bz2 ] && [ ! -e a.gz ] &&
[ ! -e a ] && [ -e a.lz ] ; then printf .
else printf - ; fail=1
fi
rm -f x.lz || framework_failure
rm -f a.lz || framework_failure
cat in.bz2 > x.bz2 || framework_failure
"${ZUPDATE}" -N -1 -q x.bz2
if [ $? = 0 ] && [ ! -e x.bz2 ] && [ -e x.lz ] ; then printf .
cat in.bz2 > a.bz2 || framework_failure
"${ZUPDATE}" -N -1 -q a.bz2
if [ $? = 0 ] && [ ! -e a.bz2 ] && [ -e a.lz ] ; then printf .
else printf - ; fail=1
fi
rm -f x.lz || framework_failure
rm -f a.lz || framework_failure
mkdir tmp2
mkdir tmp2/tmp3
cat in.bz2 > tmp2/tmp3/x.bz2 || framework_failure
cat in.gz > tmp2/tmp3/x.gz || framework_failure
cat in.bz2 > tmp2/tmp3/a.bz2 || framework_failure
cat in.gz > tmp2/tmp3/a.gz || framework_failure
"${ZUPDATE}" -N -r --format=gz tmp2
if [ $? = 0 ] && [ -e tmp2/tmp3/x.bz2 ] && [ ! -e tmp2/tmp3/x.gz ] &&
[ -e tmp2/tmp3/x.lz ] ; then printf .
if [ $? = 0 ] && [ -e tmp2/tmp3/a.bz2 ] && [ ! -e tmp2/tmp3/a.gz ] &&
[ -e tmp2/tmp3/a.lz ] ; then printf .
else printf - ; fail=1
fi
rm -f tmp2/tmp3/x.lz || framework_failure
rm -f tmp2/tmp3/a.lz || framework_failure
"${ZUPDATE}" -N -r --format=bz2 tmp2
if [ $? = 0 ] && [ ! -e tmp2/tmp3/x.bz2 ] && [ ! -e tmp2/tmp3/x.gz ] &&
[ -e tmp2/tmp3/x.lz ] ; then printf .
if [ $? = 0 ] && [ ! -e tmp2/tmp3/a.bz2 ] && [ ! -e tmp2/tmp3/a.gz ] &&
[ -e tmp2/tmp3/a.lz ] ; then printf .
else printf - ; fail=1
fi
rm -r tmp2 || framework_failure

27
zcat.cc
View file

@ -1,5 +1,5 @@
/* Zcat - decompress and concatenate files to standard output
Copyright (C) 2010-2015 Antonio Diaz Diaz.
Copyright (C) 2010-2016 Antonio Diaz Diaz.
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
@ -90,14 +90,14 @@ Line_number line_number;
void show_help()
{
std::printf( "Zcat copies each given file (\"-\" means standard input), to standard\n"
"output. If any given file is compressed, its decompressed content is\n"
"used. If a given file does not exist, and its name does not end with one\n"
"of the known extensions, zcat tries the compressed file names\n"
"corresponding to the supported formats. If no files are specified,\n"
"data is read from standard input, decompressed if needed, and sent to\n"
"standard output. Data read from standard input must be of the same type;\n"
"all uncompressed or all in the same compression format.\n"
std::printf( "Zcat copies each given file to standard output. If any given file is\n"
"compressed, its decompressed content is used. If a given file does not\n"
"exist, and its name does not end with one of the known extensions, zcat\n"
"tries the compressed file names corresponding to the supported formats.\n"
"\nIf no files are specified, or if a file is specified as '-', data is\n"
"read from standard input, decompressed if needed, and sent to standard\n"
"output. Data read from standard input must be of the same type; all\n"
"uncompressed or all in the same compression format.\n"
"\nThe supported formats are bzip2, gzip, lzip and xz.\n"
"\nUsage: zcat [options] [files]\n"
"\nExit status is 0 if no errors occurred, non-zero otherwise.\n"
@ -346,13 +346,18 @@ int main( const int argc, const char * const argv[] )
for( ; argind < parser.arguments(); ++argind )
filenames.push_back( parser.argument( argind ) );
if( filenames.empty() ) filenames.push_back("-");
if( filenames.empty() ) filenames.push_back( "-" );
int retval = 0;
bool error = false;
bool stdin_used = false;
while( next_filename( filenames, input_filename, error, recursive ) )
{
if( input_filename.empty() ) infd = STDIN_FILENO;
if( input_filename.empty() )
{
if( stdin_used ) continue; else stdin_used = true;
infd = STDIN_FILENO;
}
else
{
infd = open_instream( input_filename, format_index < 0 );

View file

@ -1,5 +1,5 @@
/* Common code for zcat and zgrep
Copyright (C) 2010-2015 Antonio Diaz Diaz.
Copyright (C) 2010-2016 Antonio Diaz Diaz.
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

28
zcmp.cc
View file

@ -1,5 +1,5 @@
/* Zcmp - decompress and compare two files byte by byte
Copyright (C) 2010-2015 Antonio Diaz Diaz.
Copyright (C) 2010-2016 Antonio Diaz Diaz.
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
@ -50,11 +50,11 @@ namespace {
void show_help()
{
std::printf( "Zcmp compares two files (\"-\" means standard input), and if they\n"
"differ, tells the first byte and line number where they differ. Bytes\n"
"and lines are numbered starting with 1. If any given file is compressed,\n"
"its decompressed content is used. Compressed files are decompressed on\n"
"the fly; no temporary files are created.\n"
std::printf( "Zcmp compares two files ('-' means standard input), and if they differ,\n"
"tells the first byte and line number where they differ. Bytes and lines\n"
"are numbered starting with 1. If any given file is compressed, its\n"
"decompressed content is used. Compressed files are decompressed on the\n"
"fly; no temporary files are created.\n"
"\nThe supported formats are bzip2, gzip, lzip and xz.\n"
"\nUsage: zcmp [options] file1 [file2]\n"
"\nCompares <file1> to <file2>. If <file2> is omitted zcmp tries the\n"
@ -106,9 +106,8 @@ long long getnum( const char * const ptr, const char ** const tailp = 0,
if( !errno && tail[0] && std::isalpha( tail[0] ) )
{
int factor = ( tail[1] == 'i' ) ? 1024 : 1000;
int exponent = 0;
bool bad_multiplier = false;
const int factor = ( tail[1] == 'i' ) ? 1024 : 1000;
int exponent = 0; // 0 = bad multiplier
switch( tail[0] )
{
case 'Y': exponent = 8; break;
@ -118,13 +117,10 @@ long long getnum( const char * const ptr, const char ** const tailp = 0,
case 'T': exponent = 4; break;
case 'G': exponent = 3; break;
case 'M': exponent = 2; break;
case 'K': if( factor == 1024 ) exponent = 1; else bad_multiplier = true;
break;
case 'k': if( factor == 1000 ) exponent = 1; else bad_multiplier = true;
break;
default : bad_multiplier = true;
case 'K': if( factor == 1024 ) exponent = 1; break;
case 'k': if( factor == 1000 ) exponent = 1; break;
}
if( bad_multiplier )
if( exponent <= 0 )
{
show_error( "Bad multiplier in numerical argument.", 0, true );
std::exit( 2 );
@ -298,7 +294,7 @@ int cmp( const long long max_size, const int infd[2],
if( verbosity >= 0 )
std::fprintf( stderr, "%s: EOF on %s\n",
program_name, filenames[rd[1]<rd[0]].c_str() );
return 1;
return 1;
}
if( min_rd != buffer_size ) break;
}

View file

@ -1,5 +1,5 @@
/* Common code for zcmp and zdiff
Copyright (C) 2010-2015 Antonio Diaz Diaz.
Copyright (C) 2010-2016 Antonio Diaz Diaz.
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

View file

@ -1,5 +1,5 @@
/* Zdiff - decompress and compare two files line by line
Copyright (C) 2010-2015 Antonio Diaz Diaz.
Copyright (C) 2010-2016 Antonio Diaz Diaz.
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
@ -48,7 +48,7 @@ std::string fifonames[2]; // names of the two fifos passed to diff
void show_help()
{
std::printf( "Zdiff compares two files (\"-\" means standard input), and if they\n"
std::printf( "Zdiff compares two files ('-' means standard input), and if they\n"
"differ, shows the differences line by line. If any given file is\n"
"compressed, its decompressed content is used. Zdiff is a front end to\n"
"the diff program and has the limitation that messages from diff refer to\n"
@ -123,12 +123,14 @@ bool set_fifonames( const std::string filenames[2] )
if( p ) { fifonames[0] = p; fifonames[0] += '/'; }
else fifonames[0] = "/tmp/";
int n = getpid();
const unsigned pos = fifonames[0].size();
unsigned pos = fifonames[0].size();
do fifonames[0].insert( pos, 1, codes[n % num_codes] );
while( n /= num_codes );
pos = fifonames[0].size();
fifonames[1] = fifonames[0];
fifonames[0] += '_'; fifonames[0] += my_basename( filenames[0].c_str() );
fifonames[1] += '-'; fifonames[1] += my_basename( filenames[1].c_str() );
fifonames[1] += '_'; fifonames[1] += my_basename( filenames[1].c_str() );
if( fifonames[1] == fifonames[0] ) fifonames[1][pos] = '-';
for( int i = 0; i < 2; ++i )
if( mkfifo( fifonames[i].c_str(), S_IRUSR | S_IWUSR ) != 0 )
@ -180,7 +182,7 @@ bool set_data_feeder( const std::string & fifoname, const int infd,
if( outfd < 0 )
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Can't open FIFO '%s' for writing: %s.\n",
std::fprintf( stderr, "%s: Can't open FIFO '%s' for writing: %s\n",
program_name, fifoname.c_str(), std::strerror( errno ) );
_exit( 2 );
}
@ -219,7 +221,7 @@ bool set_data_feeder( const std::string & fifoname, const int infd,
if( outfd < 0 )
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Can't open FIFO '%s' for writing: %s.\n",
std::fprintf( stderr, "%s: Can't open FIFO '%s' for writing: %s\n",
program_name, fifoname.c_str(), std::strerror( errno ) );
_exit( 2 );
}

View file

@ -1,5 +1,5 @@
/* Zgrep - search compressed files for a regular expression
Copyright (C) 2010-2015 Antonio Diaz Diaz.
Copyright (C) 2010-2016 Antonio Diaz Diaz.
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
@ -52,10 +52,11 @@ void show_help()
"file is compressed, its decompressed content is used. If a given file\n"
"does not exist, and its name does not end with one of the known\n"
"extensions, zgrep tries the compressed file names corresponding to the\n"
"supported formats. If no files are specified, data is read from\n"
"standard input, decompressed if needed, and fed to grep. Data read from\n"
"standard input must be of the same type; all uncompressed or all\n"
"in the same compression format.\n"
"supported formats.\n"
"\nIf no files are specified, or if a file is specified as '-', data is\n"
"read from standard input, decompressed if needed, and fed to grep. Data\n"
"read from standard input must be of the same type; all uncompressed or\n"
"all in the same compression format.\n"
"\nThe supported formats are bzip2, gzip, lzip and xz.\n"
"\nUsage: zgrep [options] <pattern> [files]\n"
"\nExit status is 0 if match, 1 if no match, 2 if trouble.\n"
@ -337,16 +338,21 @@ int main( const int argc, const char * const argv[] )
for( ; argind < parser.arguments(); ++argind )
filenames.push_back( parser.argument( argind ) );
if( filenames.empty() ) filenames.push_back("-");
if( filenames.empty() ) filenames.push_back( "-" );
if( show_name < 0 ) show_name = ( filenames.size() != 1 || recursive );
int retval = 1;
bool error = false;
bool stdin_used = false;
while( next_filename( filenames, input_filename, error, recursive,
false, no_messages ) )
{
if( input_filename.empty() ) infd = STDIN_FILENO;
if( input_filename.empty() )
{
if( stdin_used ) continue; else stdin_used = true;
infd = STDIN_FILENO;
}
else
{
infd = open_instream( input_filename, format_index < 0, no_messages );

View file

@ -1,5 +1,5 @@
/* Ztest - verify integrity of compressed files
Copyright (C) 2010-2015 Antonio Diaz Diaz.
Copyright (C) 2010-2016 Antonio Diaz Diaz.
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
@ -51,9 +51,10 @@ namespace {
void show_help()
{
std::printf( "Ztest verifies the integrity of the specified compressed files.\n"
"Uncompressed files are ignored. If no files are specified, the integrity\n"
"of compressed data read from standard input is verified. Data read from\n"
"standard input must be all in the same compression format.\n"
"Uncompressed files are ignored. If no files are specified, or if a file\n"
"is specified as '-', the integrity of compressed data read from standard\n"
"input is verified. Data read from standard input must be all in the same\n"
"compression format.\n"
"\nThe supported formats are bzip2, gzip, lzip and xz.\n"
"\nNote that some xz files lack integrity information, and therefore can't\n"
"be verified as reliably as the other formats can.\n"
@ -270,13 +271,18 @@ int main( const int argc, const char * const argv[] )
for( ; argind < parser.arguments(); ++argind )
filenames.push_back( parser.argument( argind ) );
if( filenames.empty() ) filenames.push_back("-");
if( filenames.empty() ) filenames.push_back( "-" );
int retval = 0;
bool error = false;
bool stdin_used = false;
while( next_filename( filenames, input_filename, error, recursive ) )
{
if( input_filename.empty() ) infd = STDIN_FILENO;
if( input_filename.empty() )
{
if( stdin_used ) continue; else stdin_used = true;
infd = STDIN_FILENO;
}
else
{
infd = open_instream( input_filename );

View file

@ -1,5 +1,5 @@
/* Zupdate - recompress bzip2, gzip, xz files to lzip files
Copyright (C) 2013-2015 Antonio Diaz Diaz.
/* Zupdate - recompress bzip2, gzip, xz files to lzip format
Copyright (C) 2013-2016 Antonio Diaz Diaz.
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
@ -72,7 +72,7 @@ void show_help()
"\nOptions:\n"
" -h, --help display this help and exit\n"
" -V, --version output version information and exit\n"
" -f, --force do not skip a file even if the .lz exists\n"
" -f, --force don't skip a file even if the .lz exists\n"
" -k, --keep keep (don't delete) input files\n"
" -l, --lzip-verbose pass a -v option to the lzip compressor\n"
" -M, --format=<list> process only the formats in <list>\n"
@ -94,10 +94,10 @@ int cant_execute( const std::string & command, const int status )
if( verbosity >= 0 )
{
if( WIFEXITED( status ) )
std::fprintf( stderr, "%s: Error executing '%s'. Exit status = %d.\n",
std::fprintf( stderr, "%s: Error executing '%s'. Exit status = %d\n",
program_name, command.c_str(), WEXITSTATUS( status ) );
else
std::fprintf( stderr, "%s: Can't execute '%s'.\n",
std::fprintf( stderr, "%s: Can't execute '%s'\n",
program_name, command.c_str() );
}
return 1;
@ -162,7 +162,7 @@ int zupdate_file( const std::string & name, const char * const lzip_name,
if( stat( name.c_str(), &in_stats ) != 0 ) // check input file
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Can't stat input file '%s': %s.\n",
std::fprintf( stderr, "%s: Can't stat input file '%s': %s\n",
program_name, name.c_str(), std::strerror( errno ) );
return 1;
}
@ -198,7 +198,7 @@ int zupdate_file( const std::string & name, const char * const lzip_name,
if( !lz_exists ) // recompress
{
if( verbosity >= 1 )
std::fprintf( stderr, "Recompressing file '%s'.\n", name.c_str() );
std::fprintf( stderr, "Recompressing file '%s'\n", name.c_str() );
int fda[2]; // pipe between decompressor and compressor
if( pipe( fda ) < 0 )
{ show_error( "Can't create pipe", errno ); return 1; }
@ -262,13 +262,14 @@ int zupdate_file( const std::string & name, const char * const lzip_name,
{
if( lz_exists && verbosity >= 1 )
std::fprintf( stderr, "Comparing file '%s'.\n", name.c_str() );
std::fprintf( stderr, "Comparing file '%s'\n", name.c_str() );
std::string zcmp_command( invocation_name );
unsigned i = zcmp_command.size();
while( i > 0 && zcmp_command[i-1] != '/' ) --i;
zcmp_command.resize( i );
zcmp_command += "zcmp "; // ${bindir}zcmp
if( no_rcfile ) zcmp_command += "-N ";
if( verbosity < 0 ) zcmp_command += "-q ";
zcmp_command += name; zcmp_command += ' '; zcmp_command += rname;
int status = std::system( zcmp_command.c_str() );
if( status != 0 )
@ -279,7 +280,7 @@ int zupdate_file( const std::string & name, const char * const lzip_name,
if( !keep_input_files && std::remove( name.c_str() ) != 0 && errno != ENOENT )
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Can't delete input file '%s': %s.\n",
std::fprintf( stderr, "%s: Can't delete input file '%s': %s\n",
program_name, name.c_str(), std::strerror( errno ) );
return 1;
}

View file

@ -1,5 +1,5 @@
/* Zutils - Utilities dealing with compressed files
Copyright (C) 2009-2015 Antonio Diaz Diaz.
Copyright (C) 2009-2016 Antonio Diaz Diaz.
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
@ -61,7 +61,7 @@ int child_status( const pid_t pid, const char * const name )
if( tmp == -1 && errno != EINTR )
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Error checking status of '%s': %s.\n",
std::fprintf( stderr, "%s: Error checking status of '%s': %s\n",
program_name, name, std::strerror( errno ) );
_exit( 2 );
}

View file

@ -1,5 +1,5 @@
/* Zutils - Utilities dealing with compressed files
Copyright (C) 2009-2015 Antonio Diaz Diaz.
Copyright (C) 2009-2016 Antonio Diaz Diaz.
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