diff options
Diffstat (limited to 'gnu/usr.bin/gzip/unlzw.c')
-rw-r--r-- | gnu/usr.bin/gzip/unlzw.c | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/gnu/usr.bin/gzip/unlzw.c b/gnu/usr.bin/gzip/unlzw.c index 15d2a31..fe2110f 100644 --- a/gnu/usr.bin/gzip/unlzw.c +++ b/gnu/usr.bin/gzip/unlzw.c @@ -8,7 +8,7 @@ */ #ifdef RCSID -static char rcsid[] = "$Id: unlzw.c,v 0.15 1993/06/10 13:28:35 jloup Exp $"; +static char rcsid[] = "$Id: unlzw.c,v 1.3 1993/10/14 00:33:17 nate Exp $"; #endif #include <sys/types.h> @@ -32,22 +32,22 @@ typedef unsigned short count_short; typedef unsigned long cmp_code_int; #define MAXCODE(n) (1L << (n)) - + #ifndef REGISTERS # define REGISTERS 2 #endif -#define REG1 -#define REG2 -#define REG3 -#define REG4 -#define REG5 -#define REG6 -#define REG7 -#define REG8 -#define REG9 +#define REG1 +#define REG2 +#define REG3 +#define REG4 +#define REG5 +#define REG6 +#define REG7 +#define REG8 +#define REG9 #define REG10 -#define REG11 -#define REG12 +#define REG11 +#define REG12 #define REG13 #define REG14 #define REG15 @@ -116,11 +116,11 @@ typedef unsigned long cmp_code_int; # undef REG16 # define REG16 register #endif - + #ifndef BYTEORDER # define BYTEORDER 0000 #endif - + #ifndef NOALLIGN # define NOALLIGN 0 #endif @@ -189,7 +189,7 @@ int block_mode = BLOCK_MODE; /* block compress mode -C compatible with 2.0 */ * The magic header has already been checked and skipped. * bytes_in and bytes_out have been initialized. */ -int unlzw(in, out) +int unlzw(in, out) int in, out; /* input and output file descriptors */ { REG2 char_type *stackp; @@ -207,7 +207,7 @@ int unlzw(in, out) REG14 code_int maxmaxcode; REG15 int n_bits; REG16 int rsize; - + #ifdef MAXSEG_64K tab_prefix[0] = tab_prefix0; tab_prefix[1] = tab_prefix1; @@ -220,7 +220,7 @@ int unlzw(in, out) } maxbits &= BIT_MASK; maxmaxcode = MAXCODE(maxbits); - + if (maxbits > BITS) { fprintf(stderr, "\n%s: %s: compressed with %d bits, can only handle %d bits\n", @@ -237,9 +237,9 @@ int unlzw(in, out) posbits = inptr<<3; free_ent = ((block_mode) ? FIRST : 256); - + clear_tab_prefixof(); /* Initialize the first 256 entries in the table. */ - + for (code = 255 ; code >= 0 ; --code) { tab_suffixof(code) = (char_type)code; } @@ -247,16 +247,16 @@ int unlzw(in, out) REG1 int i; int e; int o; - + resetbuf: e = insize-(o = (posbits>>3)); - + for (i = 0 ; i < e ; ++i) { inbuf[i] = inbuf[i+o]; } insize = e; posbits = 0; - + if (insize < INBUF_EXTRA) { if ((rsize = read(in, (char*)inbuf+insize, INBUFSIZ)) == EOF) { read_error(); @@ -264,9 +264,9 @@ int unlzw(in, out) insize += rsize; bytes_in += (ulg)rsize; } - inbits = ((rsize != 0) ? ((long)insize - insize%n_bits)<<3 : + inbits = ((rsize != 0) ? ((long)insize - insize%n_bits)<<3 : ((long)insize<<3)-(n_bits-1)); - + while (inbits > posbits) { if (free_ent > maxcode) { posbits = ((posbits-1) + @@ -299,10 +299,10 @@ int unlzw(in, out) } incode = code; stackp = de_stack; - + if (code >= free_ent) { /* Special case for KwKwK string. */ if (code > free_ent) { -#ifdef DEBUG +#ifdef DEBUG char_type *p; posbits -= n_bits; @@ -331,11 +331,11 @@ int unlzw(in, out) code = tab_prefixof(code); } *--stackp = (char_type)(finchar = tab_suffixof(code)); - + /* And put them out in forward order */ { REG1 int i; - + if (outpos+(i = (de_stack-stackp)) >= OUTBUFSIZ) { do { if (i > OUTBUFSIZ-outpos) i = OUTBUFSIZ-outpos; @@ -364,11 +364,11 @@ int unlzw(in, out) tab_prefixof(code) = (unsigned short)oldcode; tab_suffixof(code) = (char_type)finchar; free_ent = code+1; - } + } oldcode = incode; /* Remember previous code. */ } } while (rsize != 0); - + if (!test && outpos > 0) { write_buf(out, (char*)outbuf, outpos); bytes_out += (ulg)outpos; |