Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!uakari.primate.wisc.edu!samsung!munnari.oz.au!comp.vuw.ac.nz!am.dsir.govt.nz!marcamd!mercury!kcbbs!kc From: Peter_Gutmann@kcbbs.gen.nz (Peter Gutmann) Newsgroups: comp.compression Subject: A few fixes for pgencode/pgdecode Message-ID: <1991Mar29.102051.1743@kcbbs> Date: 29 Mar 91 10:20:51 GMT Lines: 52 Organisation: Kappa Crucis Unix BBS, Auckland, New Zealand Oh dear! It appears that a line of pgdecode was truncated at 80 columns (sorry folks!). Here's the full version: It's towards the end of the pgdecode source: /* Nitpick to make sure there's an end line */ if( fgets( buffer, sizeof( buffer ), inFilePtr ) == NULL || \ strcmp( buffer, "end\n" ) ) Thanks to Michael Lawler for pointing this out. Also, after I'd posted the code I realised I was being a bit over-paranoid with the code in encodeFile()/decodeFile(). In particular replacing the two while loops: while( bitCount < LONG_CODE_BITS ) { bitBuffer |= getc( inFilePtr ) << bitCount; bitCount += CHAR_BIT; } and: while( bitCount >= CHAR_BIT ) { putc( bitBuffer & 0xFF, outFilePtr ); bitBuffer >>= CHAR_BIT; bitCount -= CHAR_BIT; } with simple if statements: if( bitCount < LONG_CODE_BITS ) and: if( bitCount >= CHAR_BIT ) should give a slight program speedup. Another thing which I think I should mention is that the encoded files may not pass unscathed through some networks: I think some of the chars produced have no EBCDIC equivalent for example (but I'll let the experts comment on that one). ---------------------------------------------------------------------------- Peter_Gutmann@kcbbs.gen.nz || peter@nacjack.gen.nz || pgut1@cs.aukuni.ac.nz (In order of decreasing reliability) Warning! Something large, scaly, and with fangs a foot long lives between and . Every now and then it kills and eats messages. If you don't receive a reply within a week, try resending...