v06i035: u16 patch 2
Brandon S. Allbery - comp.sources.misc
allbery at uunet.UU.NET
Sat Feb 4 13:16:20 AEST 1989
Posting-number: Volume 6, Issue 35
Submitted-by: tom at M.UUCP (Tom Horsley)
Archive-name: u16.patch2
This is patch #2 to the u16 16-bit LZW uncompress for IBM PCs.
It fixes some bugs with multiple file decompression. I keep
hoping I have gotten the last bug. :-).
-------------------------cut here----------------------------------
*** u16.c.v1.1 Tue Jan 3 15:34:28 1989
--- u16.c Mon Jan 30 10:27:14 1989
***************
*** 18,23 ****
--- 18,34 ----
* The fix was to add a new variable to keep track of the count
* of bits in the buffer and always check to see that there are
* enough bits for at least one new code to be extracted.
+ *
+ * Version 1.2
+ *
+ * Bug2 - fixed Sun, 29 Jan 89 14:16:45 PST
+ * reported by kwok at iris.ucdavis.edu (Conrad Kwok)
+ * (I used Conrad's suggested patches for the fix).
+ *
+ * The decompress routine uses several globals which were not
+ * properly initialized when more than one file is decompressed.
+ * Also a proper return value from decompress() was not always
+ * given.
*/
#include <stdio.h>
#include <fcntl.h>
***************
*** 94,100 ****
* message you get with the -H option.
*/
unsigned char buf[MAXBUF] = "\
! u16 - 16 bit LZW uncompress for the IBM PC, version 1.1\n\
u16 [-H] [files...]\n\
\n\
-H\tPrint this message and exit.\n\
--- 105,111 ----
* message you get with the -H option.
*/
unsigned char buf[MAXBUF] = "\
! u16 - 16 bit LZW uncompress for the IBM PC, version 1.2\n\
u16 [-H] [files...]\n\
\n\
-H\tPrint this message and exit.\n\
***************
*** 283,288 ****
--- 294,305 ----
long stacksize = 0;
#endif
+ eofmark = NULL;
+ bitsinbuf=0;
+ bufsize=0;
+ clear_flg=0;
+ free_ent=0;
+
/* No buffering on stdin, we do all our own buffering.
*/
setvbuf(stdin, NULL, _IONBF, 0);
***************
*** 296,302 ****
/* Read the iniital buffer worth of data and check magic numbers
* and flags.
*/
- bitsinbuf = 0;
ReadBuf();
bitsinbuf -= 3 * 8;
if (bufsize < 3) {
--- 313,318 ----
***************
*** 336,342 ****
finchar = oldcode = getcode();
if(oldcode == -1) /* EOF already? */
! return; /* Get out of here */
putchar((char)finchar ); /* first code must be 8 bits = char */
#ifdef DEBUG
++bytes_out;
--- 352,358 ----
finchar = oldcode = getcode();
if(oldcode == -1) /* EOF already? */
! return 1; /* Get out of here */
putchar((char)finchar ); /* first code must be 8 bits = char */
#ifdef DEBUG
++bytes_out;
=====================================================================
usenet: tahorsley at ssd.harris.com USMail: Tom Horsley
compuserve: 76505,364 511 Kingbird Circle
genie: T.HORSLEY Delray Beach, FL 33444
======================== Aging: Just say no! ========================
More information about the Comp.sources.misc
mailing list