X-Git-Url: http://git.sourceforge.jp/view?p=lha%2Flha.git;a=blobdiff_plain;f=src%2Fhuf.c;h=cc1bde4504958bb7129e501a1013588f905cf0dd;hp=93936222baa0cde6b6bbff3b275be353c1d67cc7;hb=91ead0f443e15d31a53491551c27e215fe6362da;hpb=077cef7772dffae0d607aeb199b515c5027e25c6 diff --git a/src/huf.c b/src/huf.c index 9393622..cc1bde4 100644 --- a/src/huf.c +++ b/src/huf.c @@ -5,6 +5,7 @@ /* Modified Nobutaka Watazaki */ /* */ /* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* Ver. 1.14i Support LH7 & Bug Fixed 2000.10. 6 t.okamoto */ /* ------------------------------------------------------------------------ */ #include "lha.h" @@ -25,7 +26,7 @@ unsigned short c_freq[2 * NC - 1], c_table[4096], c_code[NC], p_freq[2 * NP - 1 pt_table[256], pt_code[NPT], t_freq[2 * NT - 1]; static unsigned char *buf; -static unsigned short bufsiz; +static unsigned int bufsiz; static unsigned short blocksize; static unsigned short output_pos, output_mask; static int pbit; @@ -261,7 +262,7 @@ alloc_buf( /* void */ ) while ((buf = (unsigned char *) malloc(bufsiz)) == NULL) { bufsiz = (bufsiz / 10) * 9; if (bufsiz < 4 * 1024) - break; + fatal_error("Not enough memory"); } return buf; } @@ -272,6 +273,7 @@ encode_start_st1( /* void */ ) { int i; +#if 0 if (dicbit <= (MAX_DICBIT - 2)) { pbit = 4; /* lh4,5 etc. */ np = 14; @@ -279,6 +281,18 @@ encode_start_st1( /* void */ ) pbit = 5; /* lh6 */ np = 16; } +#endif + + if (dicbit <= 13) { + pbit = 4; /* lh4,5 etc. */ + np = 14; + } else { + pbit = 5; /* lh6,7 */ + if (dicbit == 16) + np = 17; + else + np = 16; + } for (i = 0; i < NC; i++) c_freq[i] = 0; @@ -308,7 +322,7 @@ read_pt_len(nn, nbit, i_special) short nbit; short i_special; { - short i, c, n; + int i, c, n; n = getbits(nbit); if (n == 0) { @@ -451,17 +465,32 @@ decode_p_st1( /* void */ ) void decode_start_st1( /* void */ ) { - if (dicbit <= (MAX_DICBIT - 2)) { /* 13 ... Changed N.Watazaki */ + if (dicbit <= 13) { + np = 14; + pbit = 4; + } else { + if (dicbit == 16) { + np = 17; /* for -lh7- */ + } else { + np = 16; + } + pbit = 5; + } + +#if 0 + if (dicbit <= 13) { /* 13 ... Changed N.Watazaki */ np = 14; pbit = 4; } else { np = 16; pbit = 5; } +#endif init_getbits(); blocksize = 0; } + /* Local Variables: */ -/* tab-width : 4 */ +/* mode:c */ +/* tab-width:4 */ /* End: */ -/* vi:set ts=4 */