From:	CSBVAX::MRGATE!RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP 24-AUG-1988 21:40
To:	ARISIA::EVERHART
Subj:	Re: HELP - LZW Compress & Decompress Run Time Error!


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Wed, 24 AUG 88 17:53:30 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Wed, 24 Aug 88 17:33:09 PDT
Received: by ucbvax.Berkeley.EDU (5.59/1.30)
	id AA29721; Wed, 24 Aug 88 14:46:07 PDT
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 24 Aug 88 17:58:16 GMT
From: uxc!ksuvax1!deimos!sloane%kuhub.cc.ukans.edu@oddjob.uchicago.edu  (Bob Sloane)
Organization: University of Kansas Academic Computing Services
Subject: Re: HELP - LZW Compress & Decompress Run Time Error!
Message-Id: <62@deimos.cis.ksu.edu>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

There are several problems with the LZW program posted recently.  What
was posted seems to be the same as the sources I found on DECUS tapes,
and the executables there worked.  I made the changes below, and the
compress and uncompress SEEM to work OK, but I wonder what other problems
there are that I haven't seen yet.  I think I will continue to use the
DECUS executables, which seem to work fine.  For those of you who want to
play with the sources, you will need to make the following changes. All
changes are to the file LZVIO.C.

The descriptor passed to FDL$GENERATE in routine fdl_open needs to be
changed as follows (changed lines marked with >):

From:
    fdl_descriptor->dsc$w_length = 4096;
    fdl_descriptor->dsc$b_dtype = DSC$K_DTYPE_VT;
    fdl_descriptor->dsc$b_class = DSC$K_CLASS_D;
    fdl_descriptor->dsc$a_pointer = malloc(4096);
    fab_add = &r->fab;
To:
>   fdl_descriptor->dsc$w_length = 0;
    fdl_descriptor->dsc$b_dtype = DSC$K_DTYPE_VT;
    fdl_descriptor->dsc$b_class = DSC$K_CLASS_D;
>   fdl_descriptor->dsc$a_pointer = 0;
    fab_add = &r->fab;

Since the return area is no longer allocated with malloc, you need to change
the following in fdl_open, also:

From:
    fdl_descriptor->dsc$a_pointer
        = realloc(fdl_descriptor->dsc$a_pointer, retlen + 1);
    fdl_descriptor->dsc$w_length = retlen;
To:
>2 lines deleted...
    fdl_descriptor->dsc$w_length = retlen;

You also need to change the routine fdl_free as follows:

From:
    free(fdl_descriptor->dsc$a_pointer);
    fdl_descriptor->dsc$a_pointer = NULL;
To:
>1 line deleted
>   str$free1_dx(fdl_descriptor);   /* I think this is right ??? */
    fdl_descriptor->dsc$a_pointer = NULL;

There is also a problem in the allocation of the NAM blocks. Note that
NAM.NAM$B_ESS is a byte, and NAM$C_MAXRSS is defined as 255.  255+1 is
256, which is 0 when assigned to a byte.  Make the following changes to
fdl_setup:

From:
    r->nam.nam$b_ess = NAM$C_MAXRSS + 1;        /* ... size     */
    r->nam.nam$b_rss = NAM$C_MAXRSS + 1;	/* ... max size */
To:
>   r->nam.nam$b_ess = NAM$C_MAXRSS;    /* ... size     */
>   r->nam.nam$b_rss = NAM$C_MAXRSS;    /* ... max size */

By the way, don't use LZW to compress/decompress indexed file, unless you
don't mind losing the index information.  I haven't tried the LZVIOISAM.C
that came with the distribution, but it looks like it should work. If anyone
tries it, how about posting the results.

I hope these changes fix all the problems in the programs, but I wouldn't
bet on it.  Good luck to those who are using these programs. They are
very useful.  If someone out there has more up to date sources, perhaps
they would be willing to post them?
+-------------------+-------------------------------------+------------------+
|  Bob Sloane        \Internet: SLOANE@KUHUB.CC.UKANS.EDU/Anything I said is |
|  Computer Center    \ BITNET: SLOANE@UKANVAX.BITNET   / my opinion, not my |
|  University of Kansas\  AT&T: (913) 864-0444         /  employer's.        |
+-----------------------+-----------------------------+----------------------+

