Deleted Added
sdiff udiff text old ( 146294 ) new ( 147666 )
full compact
1
2/*-----------------------------------------------------------*/
3/*--- A block-sorting, lossless compressor bzip2.c ---*/
4/*-----------------------------------------------------------*/
5
6/*--
7 This file is a part of bzip2 and/or libbzip2, a program and
8 library for lossless, block-sorting data compression.

--- 85 unchanged lines hidden (view full) ---

94
95 PATENTS:
96 To the best of my knowledge, bzip2/libbzip2 does not use any
97 patented algorithms. However, I do not have the resources
98 available to carry out a full patent search. Therefore I cannot
99 give any guarantee of the above statement.
100--*/
101
102
103
104/*----------------------------------------------------*/
105/*--- and now for something much more pleasant :-) ---*/
106/*----------------------------------------------------*/
107
108/*---------------------------------------------*/
109/*--

--- 197 unchanged lines hidden (view full) ---

307static void outOfMemory ( void ) NORETURN;
308static void configError ( void ) NORETURN;
309static void crcError ( void ) NORETURN;
310static void cleanUpAndFail ( Int32 ) NORETURN;
311static void compressedStreamEOF ( void ) NORETURN;
312
313static void copyFileName ( Char*, Char* );
314static void* myMalloc ( Int32 );
315
316
317
318/*---------------------------------------------------*/
319/*--- An implementation of 64-bit ints. Sigh. ---*/
320/*--- Roll on widespread deployment of ANSI C9X ! ---*/
321/*---------------------------------------------------*/
322

--- 129 unchanged lines hidden (view full) ---

452 &nbytes_in_lo32, &nbytes_in_hi32,
453 &nbytes_out_lo32, &nbytes_out_hi32 );
454 if (bzerr != BZ_OK) goto errhandler;
455
456 if (ferror(zStream)) goto errhandler_io;
457 ret = fflush ( zStream );
458 if (ret == EOF) goto errhandler_io;
459 if (zStream != stdout) {
460 ret = fclose ( zStream );
461 outputHandleJustInCase = NULL;
462 if (ret == EOF) goto errhandler_io;
463 }
464 outputHandleJustInCase = NULL;
465 if (ferror(stream)) goto errhandler_io;
466 ret = fclose ( stream );
467 if (ret == EOF) goto errhandler_io;

--- 96 unchanged lines hidden (view full) ---

564 BZ2_bzReadClose ( &bzerr, bzf );
565 if (bzerr != BZ_OK) panic ( "decompress:bzReadGetUnused" );
566
567 if (nUnused == 0 && myfeof(zStream)) break;
568 }
569
570 closeok:
571 if (ferror(zStream)) goto errhandler_io;
572 ret = fclose ( zStream );
573 if (ret == EOF) goto errhandler_io;
574
575 if (ferror(stream)) goto errhandler_io;
576 ret = fflush ( stream );
577 if (ret != 0) goto errhandler_io;
578 if (stream != stdout) {
579 ret = fclose ( stream );

--- 544 unchanged lines hidden (view full) ---

1124 /* Note use of stat here, not lstat. */
1125 retVal = MY_STAT( srcName, &fileMetaInfo );
1126 ERROR_IF_NOT_ZERO ( retVal );
1127# endif
1128}
1129
1130
1131static
1132void applySavedMetaInfoToOutputFile ( Char *dstName )
1133{
1134# if BZ_UNIX
1135 IntNative retVal;
1136 struct utimbuf uTimBuf;
1137
1138 uTimBuf.actime = fileMetaInfo.st_atime;
1139 uTimBuf.modtime = fileMetaInfo.st_mtime;
1140
1141 retVal = chmod ( dstName, fileMetaInfo.st_mode );
1142 ERROR_IF_NOT_ZERO ( retVal );
1143
1144 retVal = utime ( dstName, &uTimBuf );
1145 ERROR_IF_NOT_ZERO ( retVal );
1146
1147 retVal = chown ( dstName, fileMetaInfo.st_uid, fileMetaInfo.st_gid );
1148 /* chown() will in many cases return with EPERM, which can
1149 be safely ignored.
1150 */
1151# endif
1152}
1153
1154
1155/*---------------------------------------------*/
1156static
1157Bool containsDubiousChars ( Char* name )
1158{

--- 206 unchanged lines hidden (view full) ---

1365 /*--- Now the input and output handles are sane. Do the Biz. ---*/
1366 outputHandleJustInCase = outStr;
1367 deleteOutputOnInterrupt = True;
1368 compressStream ( inStr, outStr );
1369 outputHandleJustInCase = NULL;
1370
1371 /*--- If there was an I/O error, we won't get here. ---*/
1372 if ( srcMode == SM_F2F ) {
1373 applySavedMetaInfoToOutputFile ( outName );
1374 deleteOutputOnInterrupt = False;
1375 if ( !keepInputFiles ) {
1376 IntNative retVal = remove ( inName );
1377 ERROR_IF_NOT_ZERO ( retVal );
1378 }
1379 }
1380
1381 deleteOutputOnInterrupt = False;

--- 161 unchanged lines hidden (view full) ---

1543 outputHandleJustInCase = outStr;
1544 deleteOutputOnInterrupt = True;
1545 magicNumberOK = uncompressStream ( inStr, outStr );
1546 outputHandleJustInCase = NULL;
1547
1548 /*--- If there was an I/O error, we won't get here. ---*/
1549 if ( magicNumberOK ) {
1550 if ( srcMode == SM_F2F ) {
1551 applySavedMetaInfoToOutputFile ( outName );
1552 deleteOutputOnInterrupt = False;
1553 if ( !keepInputFiles ) {
1554 IntNative retVal = remove ( inName );
1555 ERROR_IF_NOT_ZERO ( retVal );
1556 }
1557 }
1558 } else {
1559 unzFailsExist = True;

--- 548 unchanged lines hidden ---