186d7f5d3SJohn Marino/* $FreeBSD: src/usr.bin/compress/doc/revision.log,v 1.3.2.1 2002/07/16 00:42:48 tjr Exp $ */ 286d7f5d3SJohn Marino/* $DragonFly: src/usr.bin/compress/doc/revision.log,v 1.2 2003/06/17 04:29:25 dillon Exp $ */ 386d7f5d3SJohn Marino 486d7f5d3SJohn Marino/* 586d7f5d3SJohn Marino * $Header: compress.c,v 4.0 85/07/30 12:50:00 joe Release $ 686d7f5d3SJohn Marino * $Log: compress.c,v $ 786d7f5d3SJohn Marino * Revision 4.0 85/07/30 12:50:00 joe 886d7f5d3SJohn Marino * Removed ferror() calls in output routine on every output except first. 986d7f5d3SJohn Marino * Prepared for release to the world. 1086d7f5d3SJohn Marino * 1186d7f5d3SJohn Marino * Revision 3.6 85/07/04 01:22:21 joe 1286d7f5d3SJohn Marino * Remove much wasted storage by overlaying hash table with the tables 1386d7f5d3SJohn Marino * used by decompress: tab_suffix[1<<BITS], stack[8000]. Updated USERMEM 1486d7f5d3SJohn Marino * computations. Fixed dump_tab() DEBUG routine. 1586d7f5d3SJohn Marino * 1686d7f5d3SJohn Marino * Revision 3.5 85/06/30 20:47:21 jaw 1786d7f5d3SJohn Marino * Change hash function to use exclusive-or. Rip out hash cache. These 1886d7f5d3SJohn Marino * speedups render the megamemory version defunct, for now. Make decoder 1986d7f5d3SJohn Marino * stack global. Parts of the RCS trunks 2.7, 2.6, and 2.1 no longer apply. 2086d7f5d3SJohn Marino * 2186d7f5d3SJohn Marino * Revision 3.4 85/06/27 12:00:00 ken 2286d7f5d3SJohn Marino * Get rid of all floating-point calculations by doing all compression ratio 2386d7f5d3SJohn Marino * calculations in fixed point. 2486d7f5d3SJohn Marino * 2586d7f5d3SJohn Marino * Revision 3.3 85/06/24 21:53:24 joe 2686d7f5d3SJohn Marino * Incorporate portability suggestion for M_XENIX. Got rid of text on #else 2786d7f5d3SJohn Marino * and #endif lines. Cleaned up #ifdefs for vax and interdata. 2886d7f5d3SJohn Marino * 2986d7f5d3SJohn Marino * Revision 3.2 85/06/06 21:53:24 jaw 3086d7f5d3SJohn Marino * Incorporate portability suggestions for Z8000, IBM PC/XT from mailing list. 3186d7f5d3SJohn Marino * Default to "quiet" output (no compression statistics). 3286d7f5d3SJohn Marino * 3386d7f5d3SJohn Marino * Revision 3.1 85/05/12 18:56:13 jaw 3486d7f5d3SJohn Marino * Integrate decompress() stack speedups (from early pointer mods by McKie). 3586d7f5d3SJohn Marino * Repair multi-file USERMEM gaffe. Unify 'force' flags to mimic semantics 3686d7f5d3SJohn Marino * of SVR2 'pack'. Streamline block-compress table clear logic. Increase 3786d7f5d3SJohn Marino * output byte count by magic number size. 3886d7f5d3SJohn Marino * 3986d7f5d3SJohn Marino * Revision 3.0 84/11/27 11:50:00 petsd!joe 4086d7f5d3SJohn Marino * Set HSIZE depending on BITS. Set BITS depending on USERMEM. Unrolled 4186d7f5d3SJohn Marino * loops in clear routines. Added "-C" flag for 2.0 compatibility. Used 4286d7f5d3SJohn Marino * unsigned compares on Perkin-Elmer. Fixed foreground check. 4386d7f5d3SJohn Marino * 4486d7f5d3SJohn Marino * Revision 2.7 84/11/16 19:35:39 ames!jaw 4586d7f5d3SJohn Marino * Cache common hash codes based on input statistics; this improves 4686d7f5d3SJohn Marino * performance for low-density raster images. Pass on #ifdef bundle 4786d7f5d3SJohn Marino * from Turkowski. 4886d7f5d3SJohn Marino * 4986d7f5d3SJohn Marino * Revision 2.6 84/11/05 19:18:21 ames!jaw 5086d7f5d3SJohn Marino * Vary size of hash tables to reduce time for small files. 5186d7f5d3SJohn Marino * Tune PDP-11 hash function. 5286d7f5d3SJohn Marino * 5386d7f5d3SJohn Marino * Revision 2.5 84/10/30 20:15:14 ames!jaw 5486d7f5d3SJohn Marino * Junk chaining; replace with the simpler (and, on the VAX, faster) 5586d7f5d3SJohn Marino * double hashing, discussed within. Make block compression standard. 5686d7f5d3SJohn Marino * 5786d7f5d3SJohn Marino * Revision 2.4 84/10/16 11:11:11 ames!jaw 5886d7f5d3SJohn Marino * Introduce adaptive reset for block compression, to boost the rate 5986d7f5d3SJohn Marino * another several percent. (See mailing list notes.) 6086d7f5d3SJohn Marino * 6186d7f5d3SJohn Marino * Revision 2.3 84/09/22 22:00:00 petsd!joe 6286d7f5d3SJohn Marino * Implemented "-B" block compress. Implemented REVERSE sorting of tab_next. 6386d7f5d3SJohn Marino * Bug fix for last bits. Changed fwrite to putchar loop everywhere. 6486d7f5d3SJohn Marino * 6586d7f5d3SJohn Marino * Revision 2.2 84/09/18 14:12:21 ames!jaw 6686d7f5d3SJohn Marino * Fold in news changes, small machine typedef from thomas, 6786d7f5d3SJohn Marino * #ifdef interdata from joe. 6886d7f5d3SJohn Marino * 6986d7f5d3SJohn Marino * Revision 2.1 84/09/10 12:34:56 ames!jaw 7086d7f5d3SJohn Marino * Configured fast table lookup for 32-bit machines. 7186d7f5d3SJohn Marino * This cuts user time in half for b <= FBITS, and is useful for news batching 7286d7f5d3SJohn Marino * from VAX to PDP sites. Also sped up decompress() [fwrite->putc] and 7386d7f5d3SJohn Marino * added signal catcher [plus beef in writeerr()] to delete effluvia. 7486d7f5d3SJohn Marino * 7586d7f5d3SJohn Marino * Revision 2.0 84/08/28 22:00:00 petsd!joe 7686d7f5d3SJohn Marino * Add check for foreground before prompting user. Insert maxbits into 7786d7f5d3SJohn Marino * compressed file. Force file being uncompressed to end with ".Z". 7886d7f5d3SJohn Marino * Added "-c" flag and "zcat". Prepared for release. 7986d7f5d3SJohn Marino * 8086d7f5d3SJohn Marino * Revision 1.10 84/08/24 18:28:00 turtlevax!ken 8186d7f5d3SJohn Marino * Will only compress regular files (no directories), added a magic number 8286d7f5d3SJohn Marino * header (plus an undocumented -n flag to handle old files without headers), 8386d7f5d3SJohn Marino * added -f flag to force overwriting of possibly existing destination file, 8486d7f5d3SJohn Marino * otherwise the user is prompted for a response. Will tack on a .Z to a 8586d7f5d3SJohn Marino * filename if it doesn't have one when decompressing. Will only replace 8686d7f5d3SJohn Marino * file if it was compressed. 8786d7f5d3SJohn Marino * 8886d7f5d3SJohn Marino * Revision 1.9 84/08/16 17:28:00 turtlevax!ken 8986d7f5d3SJohn Marino * Removed scanargs(), getopt(), added .Z extension and unlimited number of 9086d7f5d3SJohn Marino * filenames to compress. Flags may be clustered (-Ddvb12) or separated 9186d7f5d3SJohn Marino * (-D -d -v -b 12), or combination thereof. Modes and other status is 9286d7f5d3SJohn Marino * copied with copystat(). -O bug for 4.2 seems to have disappeared with 9386d7f5d3SJohn Marino * 1.8. 9486d7f5d3SJohn Marino * 9586d7f5d3SJohn Marino * Revision 1.8 84/08/09 23:15:00 joe 9686d7f5d3SJohn Marino * Made it compatible with vax version, installed jim's fixes/enhancements 9786d7f5d3SJohn Marino * 9886d7f5d3SJohn Marino * Revision 1.6 84/08/01 22:08:00 joe 9986d7f5d3SJohn Marino * Sped up algorithm significantly by sorting the compress chain. 10086d7f5d3SJohn Marino * 10186d7f5d3SJohn Marino * Revision 1.5 84/07/13 13:11:00 srd 10286d7f5d3SJohn Marino * Added C version of vax asm routines. Changed structure to arrays to 10386d7f5d3SJohn Marino * save much memory. Do unsigned compares where possible (faster on 10486d7f5d3SJohn Marino * Perkin-Elmer) 10586d7f5d3SJohn Marino * 10686d7f5d3SJohn Marino * Revision 1.4 84/07/05 03:11:11 thomas 10786d7f5d3SJohn Marino * Clean up the code a little and lint it. (Lint complains about all 10886d7f5d3SJohn Marino * the regs used in the asm, but I'm not going to "fix" this.) 10986d7f5d3SJohn Marino * 11086d7f5d3SJohn Marino * Revision 1.3 84/07/05 02:06:54 thomas 11186d7f5d3SJohn Marino * Minor fixes. 11286d7f5d3SJohn Marino * 11386d7f5d3SJohn Marino * Revision 1.2 84/07/05 00:27:27 thomas 11486d7f5d3SJohn Marino * Add variable bit length output. 11586d7f5d3SJohn Marino * 11686d7f5d3SJohn Marino */ 11786d7f5d3SJohn Marino 11886d7f5d3SJohn Marinostatic char rcs_ident[] = 11986d7f5d3SJohn Marino "$Header: compress.c,v 4.0 85/07/30 12:50:00 joe Release $"; 120