Adding upstream version 0.9~rc2.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
d35bbfc51f
commit
ca880cf76c
21 changed files with 133 additions and 71 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,12 +1,18 @@
|
||||||
|
2010-12-05 Antonio Diaz Diaz <ant_diaz@teleline.es>
|
||||||
|
|
||||||
|
* Version 0.9-rc2 released.
|
||||||
|
* zcmp.cc: Fixed deadlock when files differ.
|
||||||
|
* zgrep.cc: Fixed deadlock when binary file matches.
|
||||||
|
|
||||||
2010-11-20 Antonio Diaz Diaz <ant_diaz@teleline.es>
|
2010-11-20 Antonio Diaz Diaz <ant_diaz@teleline.es>
|
||||||
|
|
||||||
* Version 0.9-rc1 released.
|
* Version 0.9-rc1 released.
|
||||||
* configure: Added new options "DIFF" and "GREP".
|
* configure: Added new options `DIFF' and `GREP'.
|
||||||
|
|
||||||
2010-11-15 Antonio Diaz Diaz <ant_diaz@teleline.es>
|
2010-11-15 Antonio Diaz Diaz <ant_diaz@teleline.es>
|
||||||
|
|
||||||
* Version 0.8 released.
|
* Version 0.8 released.
|
||||||
* main.cc: Added new options "--zcat", "--zgrep" and "--ztest".
|
* main.cc: Added new options `--zcat', `--zgrep' and `--ztest'.
|
||||||
* zcat.cc: New file implementing zcat+cat functionality in C++.
|
* zcat.cc: New file implementing zcat+cat functionality in C++.
|
||||||
* zcmp.cc: New file implementing zcmp+cmp functionality in C++.
|
* zcmp.cc: New file implementing zcmp+cmp functionality in C++.
|
||||||
* doc/zcmp.1: New file.
|
* doc/zcmp.1: New file.
|
||||||
|
@ -18,7 +24,7 @@
|
||||||
documentation because egrep and fgrep are deprecated.
|
documentation because egrep and fgrep are deprecated.
|
||||||
* ztest.cc: New file implementing ztest functionality in C++.
|
* ztest.cc: New file implementing ztest functionality in C++.
|
||||||
* Makefile.in: Added quotes to directory names.
|
* Makefile.in: Added quotes to directory names.
|
||||||
* testsuite/check.sh: Use "test.txt" instead of "COPYING" for testing.
|
* testsuite/check.sh: Use `test.txt' instead of `COPYING' for testing.
|
||||||
* Removed environment safeguards from configure as requested by
|
* Removed environment safeguards from configure as requested by
|
||||||
Richard Stallman. Now environment variables affect configure.
|
Richard Stallman. Now environment variables affect configure.
|
||||||
|
|
||||||
|
@ -26,14 +32,14 @@
|
||||||
|
|
||||||
* Version 0.7 released.
|
* Version 0.7 released.
|
||||||
* Added new utility; ztest.
|
* Added new utility; ztest.
|
||||||
* zcat.in: Added new option "--recursive".
|
* zcat.in: Added new option `--recursive'.
|
||||||
|
|
||||||
2009-10-05 Antonio Diaz Diaz <ant_diaz@teleline.es>
|
2009-10-05 Antonio Diaz Diaz <ant_diaz@teleline.es>
|
||||||
|
|
||||||
* Version 0.6 released.
|
* Version 0.6 released.
|
||||||
* zcat.in, zgrep.in: Removed again default compressor. Format of
|
* zcat.in, zgrep.in: Removed again default compressor. Format of
|
||||||
data read from stdin is now automatically detected.
|
data read from stdin is now automatically detected.
|
||||||
* Makefile.in: Added "--name" option to help2man invocation.
|
* Makefile.in: Added `--name' option to help2man invocation.
|
||||||
|
|
||||||
2009-10-01 Antonio Diaz Diaz <ant_diaz@teleline.es>
|
2009-10-01 Antonio Diaz Diaz <ant_diaz@teleline.es>
|
||||||
|
|
||||||
|
|
2
INSTALL
2
INSTALL
|
@ -1,7 +1,7 @@
|
||||||
Requirements
|
Requirements
|
||||||
------------
|
------------
|
||||||
You will need a C++ compiler.
|
You will need a C++ compiler.
|
||||||
I use gcc 4.3.4 and 3.3.6, but the code should compile with any
|
I use gcc 4.3.5 and 3.3.6, but the code should compile with any
|
||||||
standards compliant compiler.
|
standards compliant compiler.
|
||||||
Gcc is available at http://gcc.gnu.org.
|
Gcc is available at http://gcc.gnu.org.
|
||||||
|
|
||||||
|
|
11
Makefile.in
11
Makefile.in
|
@ -26,7 +26,7 @@ $(progname)_profiled : $(objs)
|
||||||
$(CXX) $(LDFLAGS) -pg -o $@ $(objs)
|
$(CXX) $(LDFLAGS) -pg -o $@ $(objs)
|
||||||
|
|
||||||
zcat : zcat.in
|
zcat : zcat.in
|
||||||
cat $(VPATH)/zcat.in > zcat
|
cat $(VPATH)/zcat.in > $@
|
||||||
chmod a+x zcat
|
chmod a+x zcat
|
||||||
|
|
||||||
zcmp : $(zcmp_objs)
|
zcmp : $(zcmp_objs)
|
||||||
|
@ -36,19 +36,19 @@ zdiff : $(zdiff_objs)
|
||||||
$(CXX) $(LDFLAGS) -o $@ $(zdiff_objs)
|
$(CXX) $(LDFLAGS) -o $@ $(zdiff_objs)
|
||||||
|
|
||||||
zegrep : zegrep.in
|
zegrep : zegrep.in
|
||||||
cat $(VPATH)/zegrep.in > zegrep
|
cat $(VPATH)/zegrep.in > $@
|
||||||
chmod a+x zegrep
|
chmod a+x zegrep
|
||||||
|
|
||||||
zfgrep : zfgrep.in
|
zfgrep : zfgrep.in
|
||||||
cat $(VPATH)/zfgrep.in > zfgrep
|
cat $(VPATH)/zfgrep.in > $@
|
||||||
chmod a+x zfgrep
|
chmod a+x zfgrep
|
||||||
|
|
||||||
zgrep : zgrep.in
|
zgrep : zgrep.in
|
||||||
cat $(VPATH)/zgrep.in > zgrep
|
cat $(VPATH)/zgrep.in > $@
|
||||||
chmod a+x zgrep
|
chmod a+x zgrep
|
||||||
|
|
||||||
ztest : ztest.in
|
ztest : ztest.in
|
||||||
cat $(VPATH)/ztest.in > ztest
|
cat $(VPATH)/ztest.in > $@
|
||||||
chmod a+x ztest
|
chmod a+x ztest
|
||||||
|
|
||||||
main.o : main.cc
|
main.o : main.cc
|
||||||
|
@ -175,6 +175,7 @@ dist : doc
|
||||||
$(DISTNAME)/doc/$(pkgname).texinfo \
|
$(DISTNAME)/doc/$(pkgname).texinfo \
|
||||||
$(DISTNAME)/testsuite/check.sh \
|
$(DISTNAME)/testsuite/check.sh \
|
||||||
$(DISTNAME)/testsuite/test.txt \
|
$(DISTNAME)/testsuite/test.txt \
|
||||||
|
$(DISTNAME)/testsuite/test.txt.tar \
|
||||||
$(DISTNAME)/*.h \
|
$(DISTNAME)/*.h \
|
||||||
$(DISTNAME)/*.cc \
|
$(DISTNAME)/*.cc \
|
||||||
$(DISTNAME)/z*.in
|
$(DISTNAME)/z*.in
|
||||||
|
|
5
NEWS
5
NEWS
|
@ -1,3 +1,8 @@
|
||||||
Changes in version 0.9:
|
Changes in version 0.9:
|
||||||
|
|
||||||
Configure now allows the selection of diff and grep programs to use.
|
Configure now allows the selection of diff and grep programs to use.
|
||||||
|
|
||||||
|
A deadlock in zcmp.cc, which happened when files differ, has been fixed.
|
||||||
|
|
||||||
|
A deadlock in zgrep.cc, which happened when a binary file matches, has
|
||||||
|
been fixed.
|
||||||
|
|
4
configure
vendored
4
configure
vendored
|
@ -5,12 +5,12 @@
|
||||||
# This configure script is free software: you have unlimited permission
|
# This configure script is free software: you have unlimited permission
|
||||||
# to copy, distribute and modify it.
|
# to copy, distribute and modify it.
|
||||||
#
|
#
|
||||||
# Date of this version: 2010-11-20
|
# Date of this version: 2010-12-05
|
||||||
|
|
||||||
args=
|
args=
|
||||||
no_create=
|
no_create=
|
||||||
pkgname=zutils
|
pkgname=zutils
|
||||||
pkgversion=0.9-rc1
|
pkgversion=0.9-rc2
|
||||||
progname=zutils
|
progname=zutils
|
||||||
srctrigger=zutils.h
|
srctrigger=zutils.h
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||||
.TH ZCAT "1" "November 2010" "Zcat (zutils) 0.9-rc1" "User Commands"
|
.TH ZCAT "1" "December 2010" "Zcat (zutils) 0.9-rc2" "User Commands"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
Zcat \- decompress and concatenate files to standard output
|
Zcat \- decompress and concatenate files to standard output
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||||
.TH ZCMP "1" "November 2010" "Zcmp (zutils) 0.9-rc1" "User Commands"
|
.TH ZCMP "1" "December 2010" "Zcmp (zutils) 0.9-rc2" "User Commands"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
Zcmp \- decompress and compare two files byte by byte
|
Zcmp \- decompress and compare two files byte by byte
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||||
.TH ZDIFF "1" "November 2010" "Zdiff (zutils) 0.9-rc1" "User Commands"
|
.TH ZDIFF "1" "December 2010" "Zdiff (zutils) 0.9-rc2" "User Commands"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
Zdiff \- decompress and compare two files line by line
|
Zdiff \- decompress and compare two files line by line
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||||
.TH ZGREP "1" "November 2010" "Zgrep (zutils) 0.9-rc1" "User Commands"
|
.TH ZGREP "1" "December 2010" "Zgrep (zutils) 0.9-rc2" "User Commands"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
Zgrep \- search compressed files for a regular expression
|
Zgrep \- search compressed files for a regular expression
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||||
.TH ZTEST "1" "November 2010" "Ztest (zutils) 0.9-rc1" "User Commands"
|
.TH ZTEST "1" "December 2010" "Ztest (zutils) 0.9-rc2" "User Commands"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
Ztest \- verify integrity of compressed files
|
Ztest \- verify integrity of compressed files
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
|
|
@ -12,7 +12,7 @@ File: zutils.info, Node: Top, Next: Introduction, Up: (dir)
|
||||||
Zutils Manual
|
Zutils Manual
|
||||||
*************
|
*************
|
||||||
|
|
||||||
This manual is for Zutils (version 0.9-rc1, 20 November 2010).
|
This manual is for Zutils (version 0.9-rc2, 5 December 2010).
|
||||||
|
|
||||||
* Menu:
|
* Menu:
|
||||||
|
|
||||||
|
@ -531,13 +531,13 @@ Concept Index
|
||||||
|
|
||||||
Tag Table:
|
Tag Table:
|
||||||
Node: Top224
|
Node: Top224
|
||||||
Node: Introduction991
|
Node: Introduction990
|
||||||
Node: Zcat2446
|
Node: Zcat2445
|
||||||
Node: Zcmp4330
|
Node: Zcmp4329
|
||||||
Node: Zdiff6387
|
Node: Zdiff6386
|
||||||
Node: Zgrep8624
|
Node: Zgrep8623
|
||||||
Node: Ztest11391
|
Node: Ztest11390
|
||||||
Node: Problems12474
|
Node: Problems12473
|
||||||
Node: Concept Index13003
|
Node: Concept Index13002
|
||||||
|
|
||||||
End Tag Table
|
End Tag Table
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
@finalout
|
@finalout
|
||||||
@c %**end of header
|
@c %**end of header
|
||||||
|
|
||||||
@set UPDATED 20 November 2010
|
@set UPDATED 5 December 2010
|
||||||
@set VERSION 0.9-rc1
|
@set VERSION 0.9-rc2
|
||||||
|
|
||||||
@dircategory Data Compression
|
@dircategory Data Compression
|
||||||
@direntry
|
@direntry
|
||||||
|
@ -14,6 +14,7 @@
|
||||||
@end direntry
|
@end direntry
|
||||||
|
|
||||||
|
|
||||||
|
@ifnothtml
|
||||||
@titlepage
|
@titlepage
|
||||||
@title Zutils
|
@title Zutils
|
||||||
@subtitle Utilities dealing with compressed files
|
@subtitle Utilities dealing with compressed files
|
||||||
|
@ -24,7 +25,6 @@
|
||||||
@vskip 0pt plus 1filll
|
@vskip 0pt plus 1filll
|
||||||
@end titlepage
|
@end titlepage
|
||||||
|
|
||||||
@ifnothtml
|
|
||||||
@contents
|
@contents
|
||||||
@end ifnothtml
|
@end ifnothtml
|
||||||
|
|
||||||
|
|
1
main.cc
1
main.cc
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
|
#include <csignal>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
|
@ -37,6 +37,9 @@ done
|
||||||
|
|
||||||
printf "testing zutils-%s..." "$2"
|
printf "testing zutils-%s..." "$2"
|
||||||
cat "${testdir}"/test.txt > in || framework_failure
|
cat "${testdir}"/test.txt > in || framework_failure
|
||||||
|
cat "${testdir}"/test.txt.tar > in.tar || framework_failure
|
||||||
|
printf "01234567890" > pin.tar || framework_failure
|
||||||
|
cat in.tar in.tar in.tar in.tar >> pin.tar || framework_failure
|
||||||
cat in > -in- || framework_failure
|
cat in > -in- || framework_failure
|
||||||
cat in.lz > -in-.lz || framework_failure
|
cat in.lz > -in-.lz || framework_failure
|
||||||
cat in.lz > lz_only.lz || framework_failure
|
cat in.lz > lz_only.lz || framework_failure
|
||||||
|
@ -84,6 +87,8 @@ for i in ${extensions}; do
|
||||||
printf .
|
printf .
|
||||||
done
|
done
|
||||||
|
|
||||||
|
"${ZCMP}" in.tar pin.tar > /dev/null
|
||||||
|
if [ $? != 1 ] ; then fail=1 ; printf - ; else printf . ; fi
|
||||||
"${ZCMP}" - || fail=1
|
"${ZCMP}" - || fail=1
|
||||||
printf .
|
printf .
|
||||||
"${ZCMP}" in in || fail=1
|
"${ZCMP}" in in || fail=1
|
||||||
|
@ -130,6 +135,8 @@ for i in ${extensions}; do
|
||||||
printf .
|
printf .
|
||||||
done
|
done
|
||||||
|
|
||||||
|
#"${ZDIFF}" in.tar pin.tar > /dev/null
|
||||||
|
#if [ $? != 1 ] ; then fail=1 ; printf - ; else printf . ; fi
|
||||||
"${ZDIFF}" - || fail=1
|
"${ZDIFF}" - || fail=1
|
||||||
printf .
|
printf .
|
||||||
"${ZDIFF}" in in || fail=1
|
"${ZDIFF}" in in || fail=1
|
||||||
|
@ -168,44 +175,56 @@ printf .
|
||||||
|
|
||||||
printf "\ntesting zgrep-%s..." "$2"
|
printf "\ntesting zgrep-%s..." "$2"
|
||||||
for i in ${extensions}; do
|
for i in ${extensions}; do
|
||||||
"${ZGREP}" License in.$i > /dev/null || fail=1
|
"${ZGREP}" "GNU" in.$i > /dev/null || fail=1
|
||||||
"${ZGREP}" nx_pattern in.$i > /dev/null && fail=1
|
"${ZGREP}" "nx_pattern" in.$i > /dev/null && fail=1
|
||||||
printf .
|
printf .
|
||||||
done
|
done
|
||||||
|
|
||||||
"${ZGREP}" -r License . > /dev/null || fail=1
|
"${ZGREP}" "GNU" < pin.tar > /dev/null || fail=1
|
||||||
printf .
|
printf .
|
||||||
"${ZGREP}" nx_pattern -r . in > /dev/null && fail=1
|
"${ZGREP}" "GNU" pin.tar > /dev/null || fail=1
|
||||||
printf .
|
printf .
|
||||||
"${ZGREP}" License < in > /dev/null || fail=1
|
"${ZGREP}" -r "GNU" . > /dev/null || fail=1
|
||||||
printf .
|
printf .
|
||||||
"${ZGREP}" License < in.gz > /dev/null || fail=1
|
"${ZGREP}" "nx_pattern" -r . in > /dev/null && fail=1
|
||||||
printf .
|
printf .
|
||||||
"${ZGREP}" License < in.bz2 > /dev/null || fail=1
|
"${ZGREP}" "GNU" < in > /dev/null || fail=1
|
||||||
printf .
|
printf .
|
||||||
"${ZGREP}" License < in.lz > /dev/null || fail=1
|
"${ZGREP}" "GNU" < in.gz > /dev/null || fail=1
|
||||||
printf .
|
printf .
|
||||||
"${ZGREP}" License in > /dev/null || fail=1
|
"${ZGREP}" "GNU" < in.bz2 > /dev/null || fail=1
|
||||||
printf .
|
printf .
|
||||||
"${ZGREP}" License -- -in- > /dev/null || fail=1
|
"${ZGREP}" "GNU" < in.lz > /dev/null || fail=1
|
||||||
printf .
|
printf .
|
||||||
"${ZGREP}" License -- -in-.lz > /dev/null || fail=1
|
"${ZGREP}" "GNU" in > /dev/null || fail=1
|
||||||
printf .
|
printf .
|
||||||
"${ZGREP}" License in in.gz in.bz2 in.lz -- -in- > /dev/null || fail=1
|
"${ZGREP}" "GNU" -- -in- > /dev/null || fail=1
|
||||||
printf .
|
printf .
|
||||||
"${ZEGREP}" License in > /dev/null || fail=1
|
"${ZGREP}" "GNU" -- -in-.lz > /dev/null || fail=1
|
||||||
printf .
|
printf .
|
||||||
"${ZFGREP}" License in > /dev/null || fail=1
|
"${ZGREP}" "GNU" in in.gz in.bz2 in.lz -- -in- > /dev/null || fail=1
|
||||||
|
printf .
|
||||||
|
"${ZEGREP}" "GNU" in > /dev/null || fail=1
|
||||||
|
printf .
|
||||||
|
"${ZFGREP}" "GNU" in > /dev/null || fail=1
|
||||||
printf .
|
printf .
|
||||||
|
|
||||||
|
|
||||||
printf "\ntesting ztest-%s..." "$2"
|
printf "\ntesting ztest-%s..." "$2"
|
||||||
"${ZTEST}" in in.gz in.bz2 in.lz -- -in- || fail=1
|
"${ZTEST}" in in.gz in.bz2 in.lz -- -in- || fail=1
|
||||||
printf .
|
printf .
|
||||||
|
"${ZTEST}" < in.gz || fail=1
|
||||||
|
printf .
|
||||||
|
"${ZTEST}" < in.bz2 || fail=1
|
||||||
|
printf .
|
||||||
|
"${ZTEST}" < in.lz || fail=1
|
||||||
|
printf .
|
||||||
"${ZTEST}" -r . || fail=1
|
"${ZTEST}" -r . || fail=1
|
||||||
printf .
|
printf .
|
||||||
printf "LZIPvs0000000000000000000000" | "${ZTEST}" 2>/dev/null && fail=1
|
"${ZTEST}" < in 2>/dev/null
|
||||||
printf .
|
if [ $? = 0 ] ; then fail=1 ; printf - ; else printf . ; fi
|
||||||
|
printf "LZIPvs0000000000000000000000" | "${ZTEST}" 2>/dev/null
|
||||||
|
if [ $? = 0 ] ; then fail=1 ; printf - ; else printf . ; fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
if [ ${fail} = 0 ] ; then
|
if [ ${fail} = 0 ] ; then
|
||||||
|
|
BIN
testsuite/test.txt.tar
Normal file
BIN
testsuite/test.txt.tar
Normal file
Binary file not shown.
4
zcat.cc
4
zcat.cc
|
@ -198,13 +198,13 @@ int cat( int infd, const std::string & input_filename,
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
if( !set_data_feeder( &infd, &pid ) ) retval = 1;
|
if( !set_data_feeder( &infd, &pid ) ) retval = 1;
|
||||||
else
|
else
|
||||||
{
|
|
||||||
retval = do_cat( infd, buffer_size, inbuf, outbuf,
|
retval = do_cat( infd, buffer_size, inbuf, outbuf,
|
||||||
input_filename, cat_options );
|
input_filename, cat_options );
|
||||||
|
if( retval == 0 )
|
||||||
if( pid && wait_for_child( pid, "data feeder" ) != 0 ) retval = 1;
|
if( pid && wait_for_child( pid, "data feeder" ) != 0 ) retval = 1;
|
||||||
|
if( retval == 0 )
|
||||||
if( close( infd ) != 0 )
|
if( close( infd ) != 0 )
|
||||||
{ show_close_error( "data feeder" ); retval = 1; }
|
{ show_close_error( "data feeder" ); retval = 1; }
|
||||||
}
|
|
||||||
delete[] inbuf; delete[] outbuf;
|
delete[] inbuf; delete[] outbuf;
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
14
zcmp.cc
14
zcmp.cc
|
@ -20,6 +20,7 @@
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
|
#include <csignal>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -469,10 +470,15 @@ int main( const int argc, const char * const argv[] )
|
||||||
|
|
||||||
int retval = cmp( max_size, infd, filenames, print_bytes );
|
int retval = cmp( max_size, infd, filenames, print_bytes );
|
||||||
|
|
||||||
if( ( ( pid[0] && wait_for_child( pid[0], "data feeder" ) != 0 ) ||
|
if( retval != 0 )
|
||||||
( pid[1] && wait_for_child( pid[1], "data feeder" ) != 0 ) ) &&
|
{
|
||||||
retval == 0 )
|
if( pid[0] ) kill( pid[0], SIGTERM );
|
||||||
retval = 2;
|
if( pid[1] ) kill( pid[1], SIGTERM );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if( ( pid[0] && wait_for_child( pid[0], "data feeder" ) != 0 ) ||
|
||||||
|
( pid[1] && wait_for_child( pid[1], "data feeder" ) != 0 ) )
|
||||||
|
retval = 2;
|
||||||
|
|
||||||
for( int i = 0; i < 2; ++i )
|
for( int i = 0; i < 2; ++i )
|
||||||
{
|
{
|
||||||
|
|
18
zgrep.cc
18
zgrep.cc
|
@ -84,9 +84,12 @@ int zgrep_stdin( int infd, const std::vector< const char * > & grep_args )
|
||||||
// parent
|
// parent
|
||||||
if( grep_pid < 0 )
|
if( grep_pid < 0 )
|
||||||
{ show_fork_error( GREP ); return 2; }
|
{ show_fork_error( GREP ); return 2; }
|
||||||
int retval = 0;
|
|
||||||
if( pid && wait_for_child( pid, "data feeder" ) != 0 ) retval = 2;
|
int retval = wait_for_child( grep_pid, GREP );
|
||||||
if( wait_for_child( grep_pid, GREP ) != 0 ) retval = 2;
|
if( retval != 1 )
|
||||||
|
{ if( pid ) kill( pid, SIGTERM ); }
|
||||||
|
else
|
||||||
|
if( pid && wait_for_child( pid, "data feeder" ) != 0 ) retval = 2;
|
||||||
if( close( infd ) != 0 )
|
if( close( infd ) != 0 )
|
||||||
{ show_close_error( "data feeder" ); return 2; }
|
{ show_close_error( "data feeder" ); return 2; }
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -146,9 +149,12 @@ int zgrep_file( int infd, const std::string & input_filename,
|
||||||
}
|
}
|
||||||
if( size < buffer_size ) break;
|
if( size < buffer_size ) break;
|
||||||
}
|
}
|
||||||
int retval = 0;
|
|
||||||
if( pid && wait_for_child( pid, "data feeder" ) != 0 ) retval = 2;
|
int retval = wait_for_child( grep_pid, GREP );
|
||||||
if( wait_for_child( grep_pid, GREP ) != 0 ) retval = 2;
|
if( retval != 1 )
|
||||||
|
{ if( pid ) kill( pid, SIGTERM ); }
|
||||||
|
else
|
||||||
|
if( pid && wait_for_child( pid, "data feeder" ) != 0 ) retval = 2;
|
||||||
if( grep_list && retval == 0 )
|
if( grep_list && retval == 0 )
|
||||||
std::printf( "%s\n", input_filename.c_str() );
|
std::printf( "%s\n", input_filename.c_str() );
|
||||||
if( close( infd ) != 0 )
|
if( close( infd ) != 0 )
|
||||||
|
|
34
ztest.cc
34
ztest.cc
|
@ -42,12 +42,12 @@ int ztest_stdin( const int infd,
|
||||||
int magic_size = 0;
|
int magic_size = 0;
|
||||||
if( !test_format( infd, file_type, &magic_data, &magic_size ) )
|
if( !test_format( infd, file_type, &magic_data, &magic_size ) )
|
||||||
{ show_error( "Unknown data format read from stdin." ); return 2; }
|
{ show_error( "Unknown data format read from stdin." ); return 2; }
|
||||||
int fda[2];
|
int fda[2]; // pipe from feeder
|
||||||
if( pipe( fda ) < 0 )
|
if( pipe( fda ) < 0 )
|
||||||
{ show_error( "Can't create pipe", errno ); return 1; }
|
{ show_error( "Can't create pipe", errno ); return 1; }
|
||||||
const pid_t pid = fork();
|
|
||||||
|
|
||||||
if( pid == 0 ) // child (decompressor)
|
const pid_t pid = fork();
|
||||||
|
if( pid == 0 ) // child1 (decompressor)
|
||||||
{
|
{
|
||||||
if( dup2( fda[0], STDIN_FILENO ) >= 0 &&
|
if( dup2( fda[0], STDIN_FILENO ) >= 0 &&
|
||||||
close( fda[0] ) == 0 && close( fda[1] ) == 0 )
|
close( fda[0] ) == 0 && close( fda[1] ) == 0 )
|
||||||
|
@ -66,11 +66,26 @@ int ztest_stdin( const int infd,
|
||||||
// parent
|
// parent
|
||||||
if( pid < 0 )
|
if( pid < 0 )
|
||||||
{ show_fork_error( file_type.c_str() ); return 1; }
|
{ show_fork_error( file_type.c_str() ); return 1; }
|
||||||
close( fda[0] );
|
|
||||||
if( !feed_data( infd, fda[1], magic_data, magic_size ) ) return 1;
|
const pid_t pid2 = fork();
|
||||||
if( close( fda[1] ) != 0 )
|
if( pid2 == 0 ) // child2 (decompressor feeder)
|
||||||
{ show_close_error( "data feeder" ); return 1; }
|
{
|
||||||
return wait_for_child( pid, file_type.c_str() );
|
if( close( fda[0] ) != 0 ||
|
||||||
|
!feed_data( infd, fda[1], magic_data, magic_size ) )
|
||||||
|
_exit( 1 );
|
||||||
|
if( close( fda[1] ) != 0 )
|
||||||
|
{ show_close_error( "decompressor feeder" ); _exit( 1 ); }
|
||||||
|
_exit( 0 );
|
||||||
|
}
|
||||||
|
// parent
|
||||||
|
if( pid2 < 0 )
|
||||||
|
{ show_fork_error( "decompressor feeder" ); return 1; }
|
||||||
|
|
||||||
|
close( fda[0] ); close( fda[1] );
|
||||||
|
int retval = wait_for_child( pid, file_type.c_str(), 1 );
|
||||||
|
if( retval == 0 && wait_for_child( pid2, "decompressor feeder" ) != 0 )
|
||||||
|
retval = 1;
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,5 +116,6 @@ int ztest_file( const int infd, const std::string & input_filename,
|
||||||
// parent
|
// parent
|
||||||
if( pid < 0 )
|
if( pid < 0 )
|
||||||
{ show_fork_error( file_type.c_str() ); return 1; }
|
{ show_fork_error( file_type.c_str() ); return 1; }
|
||||||
return wait_for_child( pid, file_type.c_str() );
|
|
||||||
|
return wait_for_child( pid, file_type.c_str(), 1 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,7 +305,8 @@ bool test_format( const int infd, std::string & file_type,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wait_for_child( const pid_t pid, const char * const name )
|
int wait_for_child( const pid_t pid, const char * const name,
|
||||||
|
const int eretval )
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
while( waitpid( pid, &status, 0 ) == -1 )
|
while( waitpid( pid, &status, 0 ) == -1 )
|
||||||
|
@ -315,10 +316,10 @@ int wait_for_child( const pid_t pid, const char * const name )
|
||||||
if( verbosity >= 0 )
|
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",
|
||||||
util_name, name, std::strerror( errno ) );
|
util_name, name, std::strerror( errno ) );
|
||||||
_exit( 1 );
|
_exit( eretval );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( WIFEXITED( status ) ) return WEXITSTATUS( status );
|
if( WIFEXITED( status ) ) return WEXITSTATUS( status );
|
||||||
else return 1;
|
return eretval;
|
||||||
}
|
}
|
||||||
|
|
3
zutils.h
3
zutils.h
|
@ -54,4 +54,5 @@ void internal_error( const char * const msg );
|
||||||
bool test_format( const int infd, std::string & file_type,
|
bool test_format( const int infd, std::string & file_type,
|
||||||
const uint8_t ** magic_data, int * magic_sizep );
|
const uint8_t ** magic_data, int * magic_sizep );
|
||||||
|
|
||||||
int wait_for_child( const pid_t pid, const char * const name );
|
int wait_for_child( const pid_t pid, const char * const name,
|
||||||
|
const int eretval = 2 );
|
||||||
|
|
Loading…
Add table
Reference in a new issue