sources-request@mirror.UUCP (06/26/86)
Submitted by: condor!genrad!panda!talcott!seismo!vrdxhq!BMS-AT!stuart Mod.sources: Volume 6, Issue 23 Archive-name: compress.xenix [ The source that was submitted had the final hunk look like this: 1380c1443 < long int num, den; /* never want 16-bit */ --- > count_int num, den; 1407a1471,1473 > #endif > #ifdef XENIX_16 > fprintf(stderr, "XENIX_16, "); My copy, and the one in the mod.sources archive, doesn't have the "never want" comment. I patched a copy of the source and compiled and ran it. Both the patched version and the "official" version work together, and generate identical output from identical input. This holds for my 4.2BSD Vax750; no guarantees on other machines, and I don't have Xenix. --r$] I recently received the shell archives for compress and related utilities. We are running a 16-bit Xenix machine as well as a 16/32 bit motorola 6350. The XENIX_16 code for compress did not work. The problem was: a) a problem with the large model code optimizer. b) the constant (1<<16) as assigned to maxcode evaluates to zero on a 16 bit machine! After fixing problem b, I removed the XENIX_16 code and instead declared the large arrays as 'huge'. This allows a small model program that uses 32-bit pointers only for codetab and htab. This also removes the kludge code for multiple arrays. Defining the big constants as long is not necessary on our compiler, but doesn't hurt and may help other 16-bit compilers. I changed the logic slightly in compress() and decompress() to allow the use of unsigned short for heavily used variables containing code values. This makes things about 5% faster on a 16-bit machine. Please mail me some comments about whether you appreciate this mail. Stuart D. Gathman <vrdxhq!BMS-AT!stuart> #!/bin/sh # This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # Contents: compress.patch echo x - compress.patch sed 's/^XX//' > "compress.patch" <<'@//E*O*F compress.patch//' XX22c22 XX< # define USERMEM 450000L /* default user memory */ XX--- XX> # define USERMEM 450000 /* default user memory */ XX46,49d45 XX< #ifndef M_XENIX XX< # define huge /* needed only for 16-bit machines */ XX< #endif XX< XX51c47 XX< # if USERMEM >= (433484L+SACREDMEM) XX--- XX> # if USERMEM >= (433484+SACREDMEM) XX78c74 XX< # define HSIZE 69001L /* 95% occupancy */ XX--- XX> # define HSIZE 69001 /* 95% occupancy */ XX81c77 XX< # define HSIZE 35023L /* 94% occupancy */ XX--- XX> # define HSIZE 35023 /* 94% occupancy */ XX92a89,98 XX> #ifdef M_XENIX /* Stupid compiler can't handle arrays with */ XX> # if BITS == 16 /* more than 65535 bytes - so we fake it */ XX> # define XENIX_16 XX> # else XX> # if BITS > 13 /* Code only handles BITS = 12, 13, or 16 */ XX> # define BITS 13 XX> # endif XX> # endif XX> #endif XX> XX259c265 XX< code_int maxmaxcode; /* should NEVER generate this code */ XX--- XX> code_int maxmaxcode = 1 << BITS; /* should NEVER generate this code */ XX261c267 XX< # define MAXCODE(n_bits) ((code_int)1 << (n_bits) - 1) XX--- XX> # define MAXCODE(n_bits) (1 << (n_bits) - 1) XX263c269 XX< # define MAXCODE(n_bits) (((code_int)1 << (n_bits)) - 1) XX--- XX> # define MAXCODE(n_bits) ((1 << (n_bits)) - 1) XX266,267c272,298 XX< count_int huge htab [HSIZE]; XX< unsigned short huge codetab [HSIZE]; XX--- XX> #ifdef XENIX_16 XX> count_int htab0[8192]; XX> count_int htab1[8192]; XX> count_int htab2[8192]; XX> count_int htab3[8192]; XX> count_int htab4[8192]; XX> count_int htab5[8192]; XX> count_int htab6[8192]; XX> count_int htab7[8192]; XX> count_int htab8[HSIZE-65536]; XX> count_int * htab[9] = { XX> htab0, htab1, htab2, htab3, htab4, htab5, htab6, htab7, htab8 }; XX> XX> #define htabof(i) (htab[(i) >> 13][(i) & 0x1fff]) XX> unsigned short code0tab[16384]; XX> unsigned short code1tab[16384]; XX> unsigned short code2tab[16384]; XX> unsigned short code3tab[16384]; XX> unsigned short code4tab[16384]; XX> unsigned short * codetab[5] = { XX> code0tab, code1tab, code2tab, code3tab, code4tab }; XX> XX> #define codetabof(i) (codetab[(i) >> 14][(i) & 0x3fff]) XX> XX> #else /* Normal machine */ XX> count_int htab [HSIZE]; XX> unsigned short codetab [HSIZE]; XX269a301 XX> #endif /* XENIX_16 */ XX283,284c315,321 XX< # define tab_suffixof(i) ((char_type huge *)(htab))[i] XX< # define de_stack ((char_type huge *)&tab_suffixof(1<<BITS)) XX--- XX> #ifdef XENIX_16 XX> # define tab_suffixof(i) ((char_type *)htab[(i)>>15])[(i) & 0x7fff] XX> # define de_stack ((char_type *)(htab2)) XX> #else /* Normal machine */ XX> # define tab_suffixof(i) ((char_type *)(htab))[i] XX> # define de_stack ((char_type *)&tab_suffixof(1<<BITS)) XX> #endif /* XENIX_16 */ XX485c522 XX< maxmaxcode = (code_int)1 << maxbits; XX--- XX> maxmaxcode = 1 << maxbits; XX513c550 XX< maxmaxcode = (code_int)1 << maxbits; XX--- XX> maxmaxcode = 1 << maxbits; XX631c668 XX< maxmaxcode = (code_int)1 << maxbits; XX--- XX> maxmaxcode = 1 << maxbits; XX675c712 XX< register code_int i = 0; /* must hold HSIZE */ XX--- XX> register code_int i = 0; XX677,678c714,719 XX< register unsigned ent; /* must hold BITS bits */ XX< register code_int disp; /* must hold HSIZE */ XX--- XX> register code_int ent; XX> #ifdef XENIX_16 XX> register code_int disp; XX> #else /* Normal machine */ XX> register int disp; XX> #endif XX809,810c850,851 XX< output( incode ) XX< code_int incode; XX--- XX> output( code ) XX> code_int code; XX821d861 XX< register unsigned short code; XX829,830c869 XX< if ( incode >= 0 ) { XX< code = incode; XX--- XX> if ( code >= 0 ) { XX863c902 XX< if (bits) XX--- XX> if(bits) XX938c977 XX< register char_type huge *stackp; XX--- XX> register char_type *stackp; XX940,941c979 XX< register unsigned short code; XX< register code_int oldcode, incode; XX--- XX> register code_int code, oldcode, incode; XX947,949c985,987 XX< for ( incode = 255; incode >= 0; incode-- ) { XX< tab_prefixof(incode) = 0; XX< tab_suffixof(incode) = (char_type)incode; XX--- XX> for ( code = 255; code >= 0; code-- ) { XX> tab_prefixof(code) = 0; XX> tab_suffixof(code) = (char_type)code; XX956c994 XX< putchar( finchar ); /* first code must be 8 bits = char */ XX--- XX> putchar( (char)finchar ); /* first code must be 8 bits = char */ XX961c999 XX< while ( (incode = getcode()) > -1 ) { XX--- XX> while ( (code = getcode()) > -1 ) { XX963d1000 XX< code = incode; XX965,966c1002,1003 XX< for ( incode = 255; incode >= 0; incode-- ) XX< tab_prefixof(incode) = 0; XX--- XX> for ( code = 255; code >= 0; code-- ) XX> tab_prefixof(code) = 0; XX969c1006 XX< if ( (incode = getcode ()) == -1 ) /* O, untimely death! */ XX--- XX> if ( (code = getcode ()) == -1 ) /* O, untimely death! */ XX971d1007 XX< code = incode; XX972a1009 XX> incode = code; XX984c1021,1025 XX< while ( code >= 256 ) { /* already unsigned compare */ XX--- XX> #ifdef SIGNED_COMPARE_SLOW XX> while ( ((unsigned long)code) >= ((unsigned long)256) ) { XX> #else XX> while ( code >= 256 ) { XX> #endif XX1000,1001c1041 XX< if ( free_ent < maxmaxcode ) { XX< code = free_ent++; XX--- XX> if ( (code=free_ent) < maxmaxcode ) { XX1003a1044 XX> free_ent = code+1; XX1025c1066,1067 XX< code_int getcode() { XX--- XX> code_int XX> getcode() { XX1030c1072 XX< register unsigned short code; XX--- XX> register code_int code; XX1093c1135 XX< return (code_int)code; XX--- XX> return code; XX1185,1186c1227,1228 XX< for ( ; ent != 0; XX< ent = (ent >= FIRST ? tab_prefixof(ent) : 0) ) { XX--- XX> for ( ; ent != NULL; XX> ent = (ent >= FIRST ? tab_prefixof(ent) : NULL) ) { XX1350c1392,1398 XX< register count_int huge *htab_p = htab+hsize; XX--- XX> #ifndef XENIX_16 /* Normal machine */ XX> register count_int *htab_p = htab+hsize; XX> #else XX> register j; XX> register long k = hsize; XX> register count_int *htab_p; XX> #endif XX1353a1402,1411 XX> #ifdef XENIX_16 XX> for(j=0; j<=8 && k>=0; j++,k-=8192) { XX> i = 8192; XX> if(k < 8192) { XX> i = k; XX> } XX> htab_p = &(htab[j][i]); XX> i -= 16; XX> if(i > 0) { XX> #else XX1354a1413 XX> #endif XX1373a1433,1436 XX> #ifdef XENIX_16 XX> } XX> } XX> #endif XX1380c1443 XX< long int num, den; XX--- XX> count_int num, den; XX1407a1471,1473 XX> #endif XX> #ifdef XENIX_16 XX> fprintf(stderr, "XENIX_16, "); @//E*O*F compress.patch// chmod u=rw,g=rw,o=rw compress.patch echo Inspecting for damage in transit... temp=/tmp/sharin$$; dtemp=/tmp/sharout$$ trap "rm -f $temp $dtemp; exit" 0 1 2 3 15 cat > $temp <<\!!! 242 1026 5968 compress.patch !!! wc compress.patch | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp if test -s $dtemp then echo "Ouch [diff of wc output]:" ; cat $dtemp else echo "No problems found." fi exit 0