head	1.7;
access;
symbols
	RELENG_6_4_0_RELEASE:1.6.14.1
	RELENG_6_4:1.6.14.1.0.4
	RELENG_6_4_BP:1.6.14.1
	RELENG_6_3_0_RELEASE:1.6.14.1
	RELENG_6_3:1.6.14.1.0.2
	RELENG_6_3_BP:1.6.14.1
	RELENG_6_2_0_RELEASE:1.6
	RELENG_6_2:1.6.0.22
	RELENG_6_2_BP:1.6
	RELENG_5_5_0_RELEASE:1.6
	RELENG_5_5:1.6.0.20
	RELENG_5_5_BP:1.6
	RELENG_6_1_0_RELEASE:1.6
	RELENG_6_1:1.6.0.18
	RELENG_6_1_BP:1.6
	RELENG_6_0_0_RELEASE:1.6
	RELENG_6_0:1.6.0.16
	RELENG_6_0_BP:1.6
	RELENG_6:1.6.0.14
	RELENG_6_BP:1.6
	RELENG_5_4_0_RELEASE:1.6
	RELENG_5_4:1.6.0.12
	RELENG_5_4_BP:1.6
	RELENG_4_11_0_RELEASE:1.5.2.1
	RELENG_4_11:1.5.2.1.0.12
	RELENG_4_11_BP:1.5.2.1
	RELENG_5_3_0_RELEASE:1.6
	RELENG_5_3:1.6.0.10
	RELENG_5_3_BP:1.6
	RELENG_5:1.6.0.8
	RELENG_5_BP:1.6
	RELENG_4_10_0_RELEASE:1.5.2.1
	RELENG_4_10:1.5.2.1.0.10
	RELENG_4_10_BP:1.5.2.1
	RELENG_5_2_1_RELEASE:1.6
	RELENG_5_2_0_RELEASE:1.6
	RELENG_5_2:1.6.0.6
	RELENG_5_2_BP:1.6
	RELENG_4_9_0_RELEASE:1.5.2.1
	RELENG_4_9:1.5.2.1.0.8
	RELENG_4_9_BP:1.5.2.1
	RELENG_5_1_0_RELEASE:1.6
	RELENG_5_1:1.6.0.4
	RELENG_5_1_BP:1.6
	RELENG_4_8_0_RELEASE:1.5.2.1
	RELENG_4_8:1.5.2.1.0.6
	RELENG_4_8_BP:1.5.2.1
	RELENG_5_0_0_RELEASE:1.6
	RELENG_5_0:1.6.0.2
	RELENG_5_0_BP:1.6
	RELENG_4_7_0_RELEASE:1.5.2.1
	RELENG_4_7:1.5.2.1.0.4
	RELENG_4_7_BP:1.5.2.1
	RELENG_4_6_2_RELEASE:1.5.2.1
	RELENG_4_6_1_RELEASE:1.5.2.1
	RELENG_4_6_0_RELEASE:1.5.2.1
	RELENG_4_6:1.5.2.1.0.2
	RELENG_4_6_BP:1.5.2.1
	RELENG_4_5_0_RELEASE:1.5.8.1
	RELENG_4_5:1.5.0.8
	RELENG_4_5_BP:1.5
	RELENG_4_4_0_RELEASE:1.5
	RELENG_4_4:1.5.0.6
	RELENG_4_4_BP:1.5
	RELENG_4_3_0_RELEASE:1.5
	RELENG_4_3:1.5.0.4
	RELENG_4_3_BP:1.5
	RELENG_4_2_0_RELEASE:1.5
	RELENG_4_1_1_RELEASE:1.5
	PRE_SMPNG:1.5
	RELENG_4_1_0_RELEASE:1.5
	RELENG_3_5_0_RELEASE:1.3.12.2
	RELENG_4_0_0_RELEASE:1.5
	RELENG_4:1.5.0.2
	RELENG_4_BP:1.5
	RELENG_3_4_0_RELEASE:1.3.12.2
	RELENG_3_3_0_RELEASE:1.3.12.2
	RELENG_3_2_PAO:1.3.0.14
	RELENG_3_2_PAO_BP:1.3
	RELENG_3_2_0_RELEASE:1.3
	RELENG_3_1_0_RELEASE:1.3
	RELENG_3:1.3.0.12
	RELENG_3_BP:1.3
	RELENG_2_2_8_RELEASE:1.3
	RELENG_3_0_0_RELEASE:1.3
	RELENG_2_2_7_RELEASE:1.3
	RELENG_2_2_6_RELEASE:1.3
	RELENG_2_2_5_RELEASE:1.3
	RELENG_2_2_2_RELEASE:1.3
	RELENG_2_2_1_RELEASE:1.3
	RELENG_2_2_0_RELEASE:1.3
	RELENG_2_1_7_RELEASE:1.3
	RELENG_2_1_6_1_RELEASE:1.3
	RELENG_2_1_6_RELEASE:1.3
	RELENG_2_2:1.3.0.10
	RELENG_2_2_BP:1.3
	RELENG_2_1_5_RELEASE:1.3
	RELENG_2_1_0_RELEASE:1.3
	RELENG_2_1_0:1.3.0.8
	RELENG_2_1_0_BP:1.3
	RELENG_2_0_5_RELEASE:1.3
	RELENG_2_0_5:1.3.0.6
	RELENG_2_0_5_BP:1.3
	RELENG_2_0_5_ALPHA:1.3
	RELEASE_2_0:1.3
	BETA_2_0:1.3
	ALPHA_2_0:1.3.0.4
	MOVED_NEWCVS:1.3
	FINAL_1_1_5:1.3
	ALPHA_1_1_5:1.3
	FINAL_1_1:1.3
	GAMMA_1_1:1.3
	BETA_1_1:1.3.0.2
	BP_BETA_1_1:1.3
	FINAL_1_0:1.3
	EPSILON_1_0:1.2
	GAMMA_1_0:1.2
	BETA_1_0:1.2
	ALPHA_1_0:1.2
	GZIP_1_1:1.1.1.1
	GNU:1.1.1;
locks; strict;
comment	@# @;


1.7
date	2007.01.31.03.44.42;	author delphij;	state dead;
branches;
next	1.6;

1.6
date	2002.01.25.15.02.01;	author nectar;	state Exp;
branches
	1.6.14.1;
next	1.5;

1.5
date	99.08.27.23.35.57;	author peter;	state Exp;
branches
	1.5.2.1
	1.5.4.1
	1.5.6.1
	1.5.8.1;
next	1.4;

1.4
date	99.05.28.13.23.27;	author kris;	state Exp;
branches;
next	1.3;

1.3
date	93.10.14.00.33.36;	author nate;	state Exp;
branches
	1.3.12.1;
next	1.2;

1.2
date	93.06.19.00.22.46;	author nate;	state Exp;
branches;
next	1.1;

1.1
date	93.06.18.18.39.39;	author nate;	state Exp;
branches
	1.1.1.1;
next	;

1.6.14.1
date	2007.02.20.08.33.30;	author delphij;	state dead;
branches;
next	;

1.5.2.1
date	2002.01.28.01.21.12;	author nectar;	state Exp;
branches;
next	1.5.2.2;

1.5.2.2
date	2012.11.17.07.23.06;	author svnexp;	state Exp;
branches;
next	;

1.5.4.1
date	2002.01.28.01.29.22;	author nectar;	state Exp;
branches;
next	;

1.5.6.1
date	2002.01.28.01.28.24;	author nectar;	state Exp;
branches;
next	;

1.5.8.1
date	2002.01.28.01.26.09;	author nectar;	state Exp;
branches;
next	;

1.3.12.1
date	99.06.07.14.07.36;	author kris;	state Exp;
branches;
next	1.3.12.2;

1.3.12.2
date	99.08.29.14.33.36;	author peter;	state Exp;
branches;
next	;

1.1.1.1
date	93.06.18.18.39.40;	author nate;	state Exp;
branches;
next	;


desc
@@


1.7
log
@Remove GNU gzip left-offs, they are no longer necessary.
@
text
@#!/bin/sh
#
# $FreeBSD: src/gnu/usr.bin/gzip/znew,v 1.6 2002/01/25 15:02:01 nectar Exp $

check=0
pipe=0
opt=
files=
keep=0
res=0
old=0
new=0
block=1024
# block is the disk block size (best guess, need not be exact)

warn="(does not preserve modes and timestamp)"
tmp=`mktemp -d -t znew`
if test -z "$tmp"; then
  echo znew: could not create temporary directory
  exit 1
fi
echo hi > $tmp/1
echo hi > $tmp/2
if test -z "`(${CPMOD-cpmod} $tmp/1 $tmp/2) 2>&1`"; then
  cpmod=${CPMOD-cpmod}
  warn=""
fi

if test -z "$cpmod" && ${TOUCH-touch} -r $tmp/1 $tmp/2 2>/dev/null; then
  cpmod="${TOUCH-touch}"
  cpmodarg="-r"
  warn="(does not preserve file modes)"
fi

# check if GZIP env. variable uses -S or --suffix
gzip -q $tmp/1
ext=`echo $tmp/1* | sed "s|$tmp/1||"`
rm -rf $tmp
if test -z "$ext"; then
  echo znew: error determining gzip extension
  exit 1
fi
if test "$ext" = ".Z"; then
  echo znew: cannot use .Z as gzip extension.
  exit 1
fi

for arg
do
  case "$arg" in
  -*)     opt="$opt $arg"; shift;;
   *)     break;;
  esac
done

if test $# -eq 0; then
  echo "recompress .Z files into $ext (gzip) files"
  echo usage: `echo $0 | sed 's,^.*/,,'` "[-tv9KP]" file.Z...
  echo "  -t tests the new files before deleting originals"
  echo "  -v be verbose"
  echo "  -9 use the slowest compression method (optimal compression)"
  echo "  -K keep a .Z file when it is smaller than the $ext file"
  echo "  -P use pipes for the conversion $warn"
  exit 1
fi

opt=`echo "$opt" | sed -e 's/ //g' -e 's/-//g'`
case "$opt" in
  *t*) check=1; opt=`echo "$opt" | sed 's/t//g'`
esac
case "$opt" in
  *K*) keep=1; opt=`echo "$opt" | sed 's/K//g'`
esac
case "$opt" in
  *P*) pipe=1; opt=`echo "$opt" | sed 's/P//g'`
esac
if test -n "$opt"; then
  opt="-$opt"
fi

for i do
  n=`echo $i | sed 's/.Z$//'`
  if test ! -f "$n.Z" ; then
    echo $n.Z not found
    res=1; continue
  fi
  test $keep -eq 1 && old=`wc -c < "$n.Z"`
  if test $pipe -eq 1; then
    if gzip -d < "$n.Z" | gzip $opt > "$n$ext"; then
      # Copy file attributes from old file to new one, if possible.
      test -n "$cpmod" && $cpmod $cpmodarg "$n.Z" "$n$ext" 2> /dev/null
    else
      echo error while recompressing $n.Z
      res=1; continue
    fi
  else
    if test $check -eq 1; then
      if cp -p "$n.Z" "$n.$$" 2> /dev/null || cp "$n.Z" "$n.$$"; then
	:
      else
	echo cannot backup "$n.Z"
        res=1; continue
      fi
    fi
    if gzip -d "$n.Z"; then
      :
    else
      test $check -eq 1 && mv "$n.$$" "$n.Z"
      echo error while uncompressing $n.Z
      res=1; continue
    fi
    if gzip $opt "$n"; then
      :
    else
      if test $check -eq 1; then
	mv "$n.$$" "$n.Z" && rm -f "$n"
        echo error while recompressing $n
      else
	# compress $n  (might be dangerous if disk full)
        echo error while recompressing $n, left uncompressed
      fi
      res=1; continue
    fi
  fi
  test $keep -eq 1 && new=`wc -c < "$n$ext"`
  if test $keep -eq 1 -a `expr \( $old + $block - 1 \) / $block` -lt \
                         `expr \( $new + $block - 1 \) / $block`; then
    if test $pipe -eq 1; then
      rm -f "$n$ext"
    elif test $check -eq 1; then
      mv "$n.$$" "$n.Z" && rm -f "$n$ext"
    else
      gzip -d "$n$ext" && compress "$n" && rm -f "$n$ext"
    fi
    echo "$n.Z smaller than $n$ext -- unchanged"

  elif test $check -eq 1; then
    if gzip -t "$n$ext" ; then
      rm -f "$n.$$" "$n.Z"
    else
      test $pipe -eq 0 && mv "$n.$$" "$n.Z"
      rm -f "$n$ext"
      echo error while testing $n$ext, $n.Z unchanged
      res=1; continue
    fi
  elif test $pipe -eq 1; then
    rm -f "$n.Z"
  fi
done
exit $res
@


1.6
log
@Use mktemp(1) when creating temporary files.
@
text
@d3 1
a3 1
# $FreeBSD$
@


1.6.14.1
log
@MFC: Replace gzip(1) with the BSD licensed version found in -HEAD.

Discussed with:	re, so, portmgr (kris)

All bugs are mine.
@
text
@d3 1
a3 1
# $FreeBSD: src/gnu/usr.bin/gzip/znew,v 1.6 2002/01/25 15:02:01 nectar Exp $
@


1.5
log
@$Id$ -> $FreeBSD$
@
text
@d17 8
a24 4
tmp=/tmp/zfoo.$$
echo hi > $tmp.1
echo hi > $tmp.2
if test -z "`(${CPMOD-cpmod} $tmp.1 $tmp.2) 2>&1`"; then
d29 1
a29 1
if test -z "$cpmod" && ${TOUCH-touch} -r $tmp.1 $tmp.2 2>/dev/null; then
d36 3
a38 3
gzip -q $tmp.1
ext=`echo $tmp.1* | sed "s|$tmp.1||"`
rm -f $tmp.[12]*
@


1.5.4.1
log
@MFC 1.6: Use mktemp(1) when creating temporary files.
@
text
@d17 4
a20 8
tmp=`mktemp -d -t znew`
if test -z "$tmp"; then
  echo znew: could not create temporary directory
  exit 1
fi
echo hi > $tmp/1
echo hi > $tmp/2
if test -z "`(${CPMOD-cpmod} $tmp/1 $tmp/2) 2>&1`"; then
d25 1
a25 1
if test -z "$cpmod" && ${TOUCH-touch} -r $tmp/1 $tmp/2 2>/dev/null; then
d32 3
a34 3
gzip -q $tmp/1
ext=`echo $tmp/1* | sed "s|$tmp/1||"`
rm -rf $tmp
@


1.5.6.1
log
@MFC 1.6: Use mktemp(1) when creating temporary files.
@
text
@d17 4
a20 8
tmp=`mktemp -d -t znew`
if test -z "$tmp"; then
  echo znew: could not create temporary directory
  exit 1
fi
echo hi > $tmp/1
echo hi > $tmp/2
if test -z "`(${CPMOD-cpmod} $tmp/1 $tmp/2) 2>&1`"; then
d25 1
a25 1
if test -z "$cpmod" && ${TOUCH-touch} -r $tmp/1 $tmp/2 2>/dev/null; then
d32 3
a34 3
gzip -q $tmp/1
ext=`echo $tmp/1* | sed "s|$tmp/1||"`
rm -rf $tmp
@


1.5.8.1
log
@MFC 1.6: Use mktemp(1) when creating temporary files.

Approved by:	re
@
text
@d17 4
a20 8
tmp=`mktemp -d -t znew`
if test -z "$tmp"; then
  echo znew: could not create temporary directory
  exit 1
fi
echo hi > $tmp/1
echo hi > $tmp/2
if test -z "`(${CPMOD-cpmod} $tmp/1 $tmp/2) 2>&1`"; then
d25 1
a25 1
if test -z "$cpmod" && ${TOUCH-touch} -r $tmp/1 $tmp/2 2>/dev/null; then
d32 3
a34 3
gzip -q $tmp/1
ext=`echo $tmp/1* | sed "s|$tmp/1||"`
rm -rf $tmp
@


1.5.2.1
log
@MFC 1.6: Use mktemp(1) when creating temporary files.

Approved by:	re
@
text
@d17 4
a20 8
tmp=`mktemp -d -t znew`
if test -z "$tmp"; then
  echo znew: could not create temporary directory
  exit 1
fi
echo hi > $tmp/1
echo hi > $tmp/2
if test -z "`(${CPMOD-cpmod} $tmp/1 $tmp/2) 2>&1`"; then
d25 1
a25 1
if test -z "$cpmod" && ${TOUCH-touch} -r $tmp/1 $tmp/2 2>/dev/null; then
d32 3
a34 3
gzip -q $tmp/1
ext=`echo $tmp/1* | sed "s|$tmp/1||"`
rm -rf $tmp
@


1.5.2.2
log
@Switch importer
@
text
@d3 1
a3 1
# $FreeBSD: stable/4/gnu/usr.bin/gzip/znew 89893 2002-01-28 01:26:09Z nectar $
@


1.4
log
@Fixes from OpenBSD:

Add $Id$
Removes temp file exploits in gzexe (predictable filenames)
Fixes some typos
Fixes a buffer overrun in gzip -S
Don't prepend /usr/local/bin to path in scripts
Correct location of /usr/share/misc/termcap

Obtained from:	OpenBSD
@
text
@d3 1
a3 1
# $Id$
@


1.3
log
@Updated gzip from version 1.2.2 to 1.2.4 due to popular demand
@
text
@d2 2
a4 1
PATH="/usr/local/bin:$PATH"; export PATH
@


1.3.12.1
log
@MFC: Fixes from OpenBSD:

Add $Id$
Removes temp file exploits in gzexe (predictable filenames)
Fixes some typos
Fixes a buffer overrun in gzip -S
Don't prepend /usr/local/bin to path in scripts
Correct location of /usr/share/misc/termcap
@
text
@a1 2
#
# $Id: znew,v 1.4 1999/05/28 13:23:27 kris Exp $
d3 1
@


1.3.12.2
log
@$Id$ -> $FreeBSD$
@
text
@d3 1
a3 1
# $FreeBSD$
@


1.2
log
@Updated gzip from 1.1 to 1.2.2
@
text
@a42 3
A=
fileno=0

d46 2
a47 5
  -*)     opt="$opt $arg";;
   *)     fileno=`expr $fileno + 1`
          eval A$fileno=\$arg
          A="$A \"\$A$fileno\""
	  ;;
d51 1
a51 1
if test $fileno -eq 0; then
a60 2

eval set "$A"                # the files are now in $1, $2, ...
@


1.1
log
@Initial revision
@
text
@d3 1
a28 1
rm -f $tmp.[12]
d30 13
d58 2
a59 2
  echo 'recompress .Z files into .gz (gzip) files'
  echo usage: `echo $0 | sed 's,^.*/,,'` "[-tv9P]" file.Z...
d63 1
a63 1
  echo "  -K keep a .Z file when it is smaller than the .gz file"
d92 1
a92 1
    if gzip -d < "$n.Z" | gzip $opt > "$n.gz"; then
d94 1
a94 1
      test -n "$cpmod" && $cpmod $cpmodarg "$n.Z" "$n.gz" 2> /dev/null
d128 1
a128 1
  test $keep -eq 1 && new=`wc -c < "$n.gz"`
d132 1
a132 1
      rm -f "$n.gz"
d134 1
a134 1
      mv "$n.$$" "$n.Z" && rm -f "$n.gz"
d136 1
a136 1
      gzip -d "$n.gz" && compress "$n" && rm -f "$n.gz"
d138 1
a138 1
    echo "$n.Z smaller than $n.gz -- unchanged"
d141 1
a141 1
    if gzip -t "$n.gz" ; then
d145 2
a146 2
      rm -f "$n.gz"
      echo error while testing $n.gz, $n.Z unchanged
@


1.1.1.1
log
@Gzip 1.1
@
text
@@
