161f28255Scgd/* 2*53d6e686Scgd * $Hdr: compress.c,v 4.0 85/07/30 12:50:00 joe Release $ 3*53d6e686Scgd * $Lg: compress.c,v $ 461f28255Scgd * Revision 4.0 85/07/30 12:50:00 joe 561f28255Scgd * Removed ferror() calls in output routine on every output except first. 661f28255Scgd * Prepared for release to the world. 761f28255Scgd * 861f28255Scgd * Revision 3.6 85/07/04 01:22:21 joe 961f28255Scgd * Remove much wasted storage by overlaying hash table with the tables 1061f28255Scgd * used by decompress: tab_suffix[1<<BITS], stack[8000]. Updated USERMEM 1161f28255Scgd * computations. Fixed dump_tab() DEBUG routine. 1261f28255Scgd * 1361f28255Scgd * Revision 3.5 85/06/30 20:47:21 jaw 1461f28255Scgd * Change hash function to use exclusive-or. Rip out hash cache. These 1561f28255Scgd * speedups render the megamemory version defunct, for now. Make decoder 1661f28255Scgd * stack global. Parts of the RCS trunks 2.7, 2.6, and 2.1 no longer apply. 1761f28255Scgd * 1861f28255Scgd * Revision 3.4 85/06/27 12:00:00 ken 1961f28255Scgd * Get rid of all floating-point calculations by doing all compression ratio 2061f28255Scgd * calculations in fixed point. 2161f28255Scgd * 2261f28255Scgd * Revision 3.3 85/06/24 21:53:24 joe 2361f28255Scgd * Incorporate portability suggestion for M_XENIX. Got rid of text on #else 2461f28255Scgd * and #endif lines. Cleaned up #ifdefs for vax and interdata. 2561f28255Scgd * 2661f28255Scgd * Revision 3.2 85/06/06 21:53:24 jaw 2761f28255Scgd * Incorporate portability suggestions for Z8000, IBM PC/XT from mailing list. 2861f28255Scgd * Default to "quiet" output (no compression statistics). 2961f28255Scgd * 3061f28255Scgd * Revision 3.1 85/05/12 18:56:13 jaw 3161f28255Scgd * Integrate decompress() stack speedups (from early pointer mods by McKie). 3261f28255Scgd * Repair multi-file USERMEM gaffe. Unify 'force' flags to mimic semantics 3361f28255Scgd * of SVR2 'pack'. Streamline block-compress table clear logic. Increase 3461f28255Scgd * output byte count by magic number size. 3561f28255Scgd * 3661f28255Scgd * Revision 3.0 84/11/27 11:50:00 petsd!joe 3761f28255Scgd * Set HSIZE depending on BITS. Set BITS depending on USERMEM. Unrolled 3861f28255Scgd * loops in clear routines. Added "-C" flag for 2.0 compatibility. Used 3961f28255Scgd * unsigned compares on Perkin-Elmer. Fixed foreground check. 4061f28255Scgd * 4161f28255Scgd * Revision 2.7 84/11/16 19:35:39 ames!jaw 4261f28255Scgd * Cache common hash codes based on input statistics; this improves 4361f28255Scgd * performance for low-density raster images. Pass on #ifdef bundle 4461f28255Scgd * from Turkowski. 4561f28255Scgd * 4661f28255Scgd * Revision 2.6 84/11/05 19:18:21 ames!jaw 4761f28255Scgd * Vary size of hash tables to reduce time for small files. 4861f28255Scgd * Tune PDP-11 hash function. 4961f28255Scgd * 5061f28255Scgd * Revision 2.5 84/10/30 20:15:14 ames!jaw 5161f28255Scgd * Junk chaining; replace with the simpler (and, on the VAX, faster) 5261f28255Scgd * double hashing, discussed within. Make block compression standard. 5361f28255Scgd * 5461f28255Scgd * Revision 2.4 84/10/16 11:11:11 ames!jaw 5561f28255Scgd * Introduce adaptive reset for block compression, to boost the rate 5661f28255Scgd * another several percent. (See mailing list notes.) 5761f28255Scgd * 5861f28255Scgd * Revision 2.3 84/09/22 22:00:00 petsd!joe 5961f28255Scgd * Implemented "-B" block compress. Implemented REVERSE sorting of tab_next. 6061f28255Scgd * Bug fix for last bits. Changed fwrite to putchar loop everywhere. 6161f28255Scgd * 6261f28255Scgd * Revision 2.2 84/09/18 14:12:21 ames!jaw 6361f28255Scgd * Fold in news changes, small machine typedef from thomas, 6461f28255Scgd * #ifdef interdata from joe. 6561f28255Scgd * 6661f28255Scgd * Revision 2.1 84/09/10 12:34:56 ames!jaw 6761f28255Scgd * Configured fast table lookup for 32-bit machines. 6861f28255Scgd * This cuts user time in half for b <= FBITS, and is useful for news batching 6961f28255Scgd * from VAX to PDP sites. Also sped up decompress() [fwrite->putc] and 7061f28255Scgd * added signal catcher [plus beef in writeerr()] to delete effluvia. 7161f28255Scgd * 7261f28255Scgd * Revision 2.0 84/08/28 22:00:00 petsd!joe 7361f28255Scgd * Add check for foreground before prompting user. Insert maxbits into 7461f28255Scgd * compressed file. Force file being uncompressed to end with ".Z". 7561f28255Scgd * Added "-c" flag and "zcat". Prepared for release. 7661f28255Scgd * 7761f28255Scgd * Revision 1.10 84/08/24 18:28:00 turtlevax!ken 7861f28255Scgd * Will only compress regular files (no directories), added a magic number 7961f28255Scgd * header (plus an undocumented -n flag to handle old files without headers), 8061f28255Scgd * added -f flag to force overwriting of possibly existing destination file, 8161f28255Scgd * otherwise the user is prompted for a response. Will tack on a .Z to a 8261f28255Scgd * filename if it doesn't have one when decompressing. Will only replace 8361f28255Scgd * file if it was compressed. 8461f28255Scgd * 8561f28255Scgd * Revision 1.9 84/08/16 17:28:00 turtlevax!ken 8661f28255Scgd * Removed scanargs(), getopt(), added .Z extension and unlimited number of 8761f28255Scgd * filenames to compress. Flags may be clustered (-Ddvb12) or separated 8861f28255Scgd * (-D -d -v -b 12), or combination thereof. Modes and other status is 8961f28255Scgd * copied with copystat(). -O bug for 4.2 seems to have disappeared with 9061f28255Scgd * 1.8. 9161f28255Scgd * 9261f28255Scgd * Revision 1.8 84/08/09 23:15:00 joe 9361f28255Scgd * Made it compatible with vax version, installed jim's fixes/enhancements 9461f28255Scgd * 9561f28255Scgd * Revision 1.6 84/08/01 22:08:00 joe 9661f28255Scgd * Sped up algorithm significantly by sorting the compress chain. 9761f28255Scgd * 9861f28255Scgd * Revision 1.5 84/07/13 13:11:00 srd 9961f28255Scgd * Added C version of vax asm routines. Changed structure to arrays to 10061f28255Scgd * save much memory. Do unsigned compares where possible (faster on 10161f28255Scgd * Perkin-Elmer) 10261f28255Scgd * 10361f28255Scgd * Revision 1.4 84/07/05 03:11:11 thomas 10461f28255Scgd * Clean up the code a little and lint it. (Lint complains about all 10561f28255Scgd * the regs used in the asm, but I'm not going to "fix" this.) 10661f28255Scgd * 10761f28255Scgd * Revision 1.3 84/07/05 02:06:54 thomas 10861f28255Scgd * Minor fixes. 10961f28255Scgd * 11061f28255Scgd * Revision 1.2 84/07/05 00:27:27 thomas 11161f28255Scgd * Add variable bit length output. 11261f28255Scgd * 11361f28255Scgd */ 11461f28255Scgd 11561f28255Scgdstatic char rcs_ident[] = 116*53d6e686Scgd "$Hdr: compress.c,v 4.0 85/07/30 12:50:00 joe Release $"; 117