Subject: bin/513: -b appears to be ignored with the standard compresser
To: None <gnats-admin@sun-lamp.cs.berkeley.edu>
From: Brad Spencer <brad@anduin.eldar.org>
List: netbsd-bugs
Date: 10/11/1994 20:35:04
>Number:         513
>Category:       bin
>Synopsis:       -b appears to be ignored with the standard compresser
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    gnats-admin (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 11 20:35:03 1994
>Originator:     Brad Spencer
>Organization:
"	Just sitt'n around at home"
>Release:        
>Environment:
	Pentium 90mhz, i386 port a couple of week old, "standard" libraries
System: NetBSD anduin.eldar.org 1.0_BETA NetBSD 1.0_BETA (ANDUIN) #10: Mon Sep 26 18:34:12 EDT 1994 brad@anduin.eldar.org:/usr/src/sys/arch/i386/compile/ANDUIN i386


>Description:
	The standard Unix compresser doesn't appear to be able to compress
	anything except with 16 bits.
>How-To-Repeat:
	compress -b12 foo
	file foo
	'foo' will report as a 16 bit compressed file
>Fix:
	I don't fully understand the compress code, but here is a fix
	that I tested with compress on SunOS.  It appears that the BITS
	define was not used correctly in this case.

*** zopen.c.orig	Tue Oct 11 20:52:56 1994
--- zopen.c	Tue Oct 11 20:47:24 1994
***************
*** 255,265 ****
  		goto middle;
  	state = S_MIDDLE;
  
! 	maxmaxcode = 1L << BITS;
  	if (fwrite(magic_header,
  	    sizeof(char), sizeof(magic_header), fp) != sizeof(magic_header))
  		return (-1);
! 	tmp = (u_char)(BITS | block_compress);
  	if (fwrite(&tmp, sizeof(char), sizeof(tmp), fp) != sizeof(tmp))
  		return (-1);
  
--- 255,265 ----
  		goto middle;
  	state = S_MIDDLE;
  
! 	maxmaxcode = 1L << maxbits;
  	if (fwrite(magic_header,
  	    sizeof(char), sizeof(magic_header), fp) != sizeof(magic_header))
  		return (-1);
! 	tmp = (u_char)(maxbits | block_compress);
  	if (fwrite(&tmp, sizeof(char), sizeof(tmp), fp) != sizeof(tmp))
  		return (-1);
  
>Audit-Trail:
>Unformatted: