clean up import, add rcsid's.

This commit is contained in:
cgd 1994-06-13 14:48:14 +00:00
parent 3b93c56b85
commit 53d6e686d5
7 changed files with 431 additions and 1359 deletions

View File

@ -1,11 +1,13 @@
# from: @(#)Makefile 5.14 (Berkeley) 6/25/90
# $Id: Makefile,v 1.3 1993/10/23 01:13:35 jtc Exp $
# USERMEM should be the amount of available user memory in bytes.
# Set it to zero, for physical memory less than 1 Meg.
USERMEM=4194304
# from: @(#)Makefile 8.2 (Berkeley) 4/17/94
# $Id: Makefile,v 1.4 1994/06/13 14:48:14 cgd Exp $
PROG= compress
CFLAGS+=-DBSD4_2 -DSACREDMEM=256000 -DUSERMEM=${USERMEM}
SRCS= compress.c zopen.c
LINKS= ${BINDIR}/compress ${BINDIR}/uncompress
MLINKS= compress.1 uncompress.1 compress.1 zcat.1
afterinstall:
install -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
${.CURDIR}/zcat.sh ${DESTDIR}/usr/bin/zcat
.include <bsd.prog.mk>

View File

@ -1,5 +1,5 @@
.\" Copyright (c) 1986, 1990 The Regents of the University of California.
.\" All rights reserved.
.\" Copyright (c) 1986, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" James A. Woods, derived from original work by Spencer Thomas
@ -33,10 +33,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)compress.1 6.10 (Berkeley) 7/30/91
.\" $Id: compress.1,v 1.2 1993/08/01 07:33:30 mycroft Exp $
.\" from: @(#)compress.1 8.2 (Berkeley) 4/18/94
.\" $Id: compress.1,v 1.3 1994/06/13 14:48:22 cgd Exp $
.\"
.Dd July 30, 1991
.Dd April 18, 1994
.Dt COMPRESS 1
.Os BSD 4.3
.Sh NAME
@ -46,97 +46,93 @@
.Nd compress and expand data
.Sh SYNOPSIS
.Nm compress
.Op Fl f
.Op Fl v
.Op Fl c
.Op Fl cfv
.Op Fl b Ar bits
.Op Ar
.Nm uncompress
.Op Fl f
.Op Fl v
.Op Fl c
.Ar
.Op Fl cfv
.Op Ar
.Nm zcat
.Op Ar
.Sh DESCRIPTION
.Nm Compress
reduces the size of the named files using adaptive Lempel-Ziv coding.
Whenever possible,
each
Each
.Ar file
is replaced by one with the extension
.Ar \&.Z ,
while keeping the same ownership modes, access and modification times.
If no files are specified, the standard input is compressed to the
standard output.
Compressed files can be restored to their original form using
.Nm uncompress
or
.Nm zcat
is renamed to the same name plus the extension
.Dq .Z .
As many of the modification time, access time, file flags, file mode,
user ID, and group ID as allowed by permissions are retained in the
new file.
If compression would not reduce the size of a
.Ar file ,
the file is ignored.
.Pp
.Nm Uncompress
restores the compressed files to their original form, renaming the
files by deleting the
.Dq .Z
extension.
.Pp
.Nm Zcat
is an alias for
.Dq "uncompress -c" .
.Pp
If renaming the files would cause files to be overwritten and the standard
input device is a terminal, the user is prompted (on the standard error
output) for confirmation.
If prompting is not possible or confirmation is not received, the files
are not overwritten.
.Pp
If no files are specified, the standard input is compressed or uncompressed
to the standard output.
If either the input and output files are not regular files, the checks for
reduction in size and file overwriting are not performed, the input file is
not removed, and the attributes of the input file are not retained.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl b
Specify the
.Ar bits
code limit (see below).
.It Fl c
Compressed or uncompressed output is written to the standard output.
No files are modified.
.It Fl f
Force compression of
.Ar file ,
even if it does not actually shrink
or the corresponding
.Ar file.Z
file already exists.
Except when run in the background under
.Pa /bin/sh ,
if
.Fl f
is not given the user is prompted as to whether an existing
.Ar file.Z
file should be overwritten.
.It Fl c
(``cat'').
.Nm Compress/uncompress
writes to the standard output; no files are changed.
The nondestructive behavior of
.Nm zcat
is identical to that of
.Nm uncompress
.Fl c .
.It Fl b
Specify
.Ar bits
code limit (see below).
even if it is not actually reduced in size.
Additionally, files are overwritten without prompting for confirmation.
.It Fl v
Print the percentage reduction of each file.
.El
.Pp
.Nm Compress
uses the modified Lempel-Ziv algorithm popularized in
"A Technique for High Performance Data Compression",
Terry A. Welch,
.Em IEEE Computer ,
vol. 17,
.no 6
(June 1984), pp. 8-19.
uses a modified Lempel-Ziv algorithm.
Common substrings in the file are first replaced by 9-bit codes 257 and up.
When code 512 is reached, the algorithm switches to 10-bit codes and
continues to use more bits until the
limit specified by the
.Fl b
flag is reached (default 16).
flag is reached (the default is 16).
.Ar Bits
must be between 9 and 16. The default can be changed in the source to allow
.Nm compress
to be run on a smaller machine.
must be between 9 and 16.
.Pp
After the
.Ar bits
limit is attained,
limit is reached,
.Nm compress
periodically checks the compression ratio. If it is increasing,
periodically checks the compression ratio.
If it is increasing,
.Nm compress
continues to use the existing code dictionary. However,
if the compression ratio decreases,
continues to use the existing code dictionary.
However, if the compression ratio decreases,
.Nm compress
discards the table of substrings and rebuilds it from scratch. This allows
the algorithm to adapt to the next "block" of the file.
.Pp
Note that the
The
.Fl b
flag is omitted for
.Ar uncompress
@ -152,90 +148,24 @@ The amount of compression obtained depends on the size of the
input, the number of
.Ar bits
per code, and the distribution of common substrings.
Typically, text such as source code or English
is reduced by 50\-60%.
Compression is generally much better than that achieved by
Huffman coding (as used in the historical command
pack),
or adaptive Huffman coding (as
used in the historical command
compact),
and takes less time to compute.
Typically, text such as source code or English is reduced by 50\-60%.
Compression is generally much better than that achieved by Huffman
coding (as used in the historical command pack), or adaptive Huffman
coding (as used in the historical command compact), and takes less
time to compute.
.Pp
If an error occurs, exit status is 1;
if the last file was not compressed because it became larger, the status
is 2; otherwise the status is 0.
.Sh DIAGNOSTICS
.Bl -tag -width flag
.It "Usage: compress [-fvc] [-b maxbits] [file ...]"
Invalid options were specified on the command line.
.It "Missing maxbits"
Maxbits must follow
.Fl b .
.It Ar file : No "not in compressed format"
The file specified to
.Ar uncompress
has not been compressed.
.It Xo
.Ar file : No "compressed with"
.Ar \&xx No "bits, can only handle"
.Ar \&yy No bits
.Xc
.Ar File
was compressed by a program that could deal with
more
.Ar bits
than the compress code on this machine.
Recompress the file with smaller
.Ar bits .
.It Ar file : No "already has .Z suffix -- no change"
The file is assumed to be already compressed.
Rename the file and try again.
.It Ar file : No "filename too long to tack on .Z"
The file cannot be compressed because its name is longer than
12 characters.
Rename and try again.
This message does not occur on
.Bx
systems.
.It Ar file No "already exists; do you wish to overwrite (y or n)?"
Respond "y" if you want the output file to be replaced; "n" if not.
.It "uncompress: corrupt input"
A
.Dv SIGSEGV
violation was detected which usually means that the input file is
corrupted.
.It Compression: Em "xx.xx%"
Percentage of the input saved by compression.
(Relevant only for
.Fl v . )
.It "-- not a regular file: unchanged"
When the input file is not a regular file,
(e.g. a directory), it is
left unaltered.
.It "-- has" Ar xx No "other links: unchanged"
The input file has links; it is left unchanged. See
.Xr ln 1
for more information.
.It "-- file unchanged"
No savings is achieved by
compression. The input remains virgin.
.El
.Sh FILES
.Bl -tag -width file.Z
.It Pa file.Z
compressed file is file.Z
.El
.Sh BUGS
Although compressed files are compatible between machines with large memory,
.Fl b Ns Ar 12
should be used for file transfer to architectures with
a small process data space (64KB or less, as exhibited by the
.Tn DEC PDP
series, the Intel 80286, etc.)
.Pp
.Nm Compress
should be more flexible about the existence of the `.Z' suffix.
The
.Nm compress
utility exits 0 on success, and >0 if an error occurs.
.Sh SEE ALSO
.Rs
.%A Welch, Terry A.
.%D June, 1984
.%T "A Technique for High Performance Data Compression"
.%J "IEEE Computer"
.%V 17:6
.%P pp. 8-19
.Re
.Sh HISTORY
The
.Nm

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,6 @@
/*
* $Header: /cvsroot/src/usr.bin/compress/doc/revision.log,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $
* $Log: revision.log,v $
* Revision 1.1.1.1 1993/03/21 09:45:37 cgd
* initial import of 386bsd-0.1 sources
*
* $Hdr: compress.c,v 4.0 85/07/30 12:50:00 joe Release $
* $Lg: compress.c,v $
* Revision 4.0 85/07/30 12:50:00 joe
* Removed ferror() calls in output routine on every output except first.
* Prepared for release to the world.
@ -116,4 +113,4 @@
*/
static char rcs_ident[] =
"$Header: /cvsroot/src/usr.bin/compress/doc/revision.log,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $";
"$Hdr: compress.c,v 4.0 85/07/30 12:50:00 joe Release $";

View File

@ -31,7 +31,8 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# @(#)zcat.sh 8.1 (Berkeley) 6/6/93
# from: @(#)zcat.sh 8.1 (Berkeley) 6/6/93
# $Id: zcat.sh,v 1.2 1994/06/13 14:48:36 cgd Exp $
#
uncompress -c $*

View File

@ -29,7 +29,8 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)zopen.3 8.1 (Berkeley) 6/9/93
.\" from: @(#)zopen.3 8.1 (Berkeley) 6/9/93
.\" $Id: zopen.3,v 1.2 1994/06/13 14:48:40 cgd Exp $
.\"
.Dd June 9, 1993
.Dt ZOPEN 3

View File

@ -36,7 +36,8 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)zopen.c 8.1 (Berkeley) 6/27/93";
/* from: static char sccsid[] = "@(#)zopen.c 8.1 (Berkeley) 6/27/93"; */
static char *rcsid = "$Id: zopen.c,v 1.2 1994/06/13 14:48:44 cgd Exp $";
#endif /* LIBC_SCCS and not lint */
/*-