|
| 1 | +Ripped from Mandrake |
| 2 | + |
| 3 | +http://bugs.gentoo.org/82192 |
| 4 | + |
| 5 | +--- bzip2-1.0.6/bzip2.1 |
| 6 | ++++ bzip2-1.0.6/bzip2.1 |
| 7 | +@@ -235,6 +235,10 @@ |
| 8 | + Suppress non-essential warning messages. Messages pertaining to |
| 9 | + I/O errors and other critical events will not be suppressed. |
| 10 | + .TP |
| 11 | ++.B \-p \-\-show\-progress |
| 12 | ++Show percentage of input\-file done and while compressing show the percentage |
| 13 | ++of the original file the new file is. |
| 14 | ++.TP |
| 15 | + .B \-v --verbose |
| 16 | + Verbose mode -- show the compression ratio for each file processed. |
| 17 | + Further \-v's increase the verbosity level, spewing out lots of |
| 18 | +--- bzip2-1.0.6/bzip2.c |
| 19 | ++++ bzip2-1.0.6/bzip2.c |
| 20 | +@@ -145,6 +145,7 @@ |
| 21 | + #include <signal.h> |
| 22 | + #include <math.h> |
| 23 | + #include <errno.h> |
| 24 | ++#include <time.h> |
| 25 | + #include <ctype.h> |
| 26 | + #include "bzlib.h" |
| 27 | + |
| 28 | +@@ -301,4 +302,5 @@ |
| 29 | + Char progNameReally[FILE_NAME_LEN]; |
| 30 | + FILE *outputHandleJustInCase; |
| 31 | + Int32 workFactor; |
| 32 | ++Char showProgress; |
| 33 | + |
| 34 | +@@ -425,6 +427,12 @@ |
| 35 | + UInt32 nbytes_in_lo32, nbytes_in_hi32; |
| 36 | + UInt32 nbytes_out_lo32, nbytes_out_hi32; |
| 37 | + Int32 bzerr, bzerr_dummy, ret; |
| 38 | ++ double fileSize = 0; /* initialized to make the compiler stop crying */ |
| 39 | ++ /* double because big files might otherwhise give |
| 40 | ++ * overflows. not long long since not all compilers |
| 41 | ++ * support that one |
| 42 | ++ */ |
| 43 | ++ time_t startTime, currentTime; |
| 44 | + |
| 45 | + SET_BINARY_MODE(stream); |
| 46 | + SET_BINARY_MODE(zStream); |
| 47 | +@@ -432,12 +440,21 @@ |
| 48 | + if (ferror(stream)) goto errhandler_io; |
| 49 | + if (ferror(zStream)) goto errhandler_io; |
| 50 | + |
| 51 | ++ if ((srcMode == SM_F2F || srcMode == SM_F2O) && showProgress == True) { |
| 52 | ++ (void)fseek(stream, 0, SEEK_END); |
| 53 | ++ fileSize = ftello(stream); |
| 54 | ++ rewind(stream); |
| 55 | ++ if (verbosity >= 1) |
| 56 | ++ fprintf(stderr, "Input-file size: %ld\n", (long)fileSize); |
| 57 | ++ } |
| 58 | ++ |
| 59 | + bzf = BZ2_bzWriteOpen ( &bzerr, zStream, |
| 60 | + blockSize100k, verbosity, workFactor ); |
| 61 | + if (bzerr != BZ_OK) goto errhandler; |
| 62 | + |
| 63 | + if (verbosity >= 2) fprintf ( stderr, "\n" ); |
| 64 | + |
| 65 | ++ time(&startTime); |
| 66 | + while (True) { |
| 67 | + |
| 68 | + if (myfeof(stream)) break; |
| 69 | +@@ -446,6 +463,22 @@ |
| 70 | + if (nIbuf > 0) BZ2_bzWrite ( &bzerr, bzf, (void*)ibuf, nIbuf ); |
| 71 | + if (bzerr != BZ_OK) goto errhandler; |
| 72 | + |
| 73 | ++ if ((srcMode == SM_F2F || srcMode == SM_F2O) && showProgress == True) { |
| 74 | ++ time(¤tTime); |
| 75 | ++ |
| 76 | ++ if ((currentTime - startTime) > 1) { /* show progress every 2 seconds */ |
| 77 | ++ double curInPos = ftello(stream); |
| 78 | ++ double curOutPos = ftello(zStream); |
| 79 | ++ |
| 80 | ++ startTime = currentTime; |
| 81 | ++ |
| 82 | ++ fprintf(stderr, "%.2f%% done", (curInPos * 100.0) / fileSize); |
| 83 | ++ if (srcMode == SM_F2F) |
| 84 | ++ fprintf(stderr, ", new size: %.2f%%", (curOutPos * 100.0) / curInPos); |
| 85 | ++ |
| 86 | ++ fprintf(stderr, " \r"); |
| 87 | ++ } |
| 88 | ++ } |
| 89 | + } |
| 90 | + |
| 91 | + BZ2_bzWriteClose64 ( &bzerr, bzf, 0, |
| 92 | +@@ -520,12 +553,14 @@ |
| 93 | + Bool uncompressStream ( FILE *zStream, FILE *stream ) |
| 94 | + { |
| 95 | + BZFILE* bzf = NULL; |
| 96 | + Int32 bzerr, bzerr_dummy, ret, nread, streamNo, i; |
| 97 | + UChar obuf[5000]; |
| 98 | + UChar unused[BZ_MAX_UNUSED]; |
| 99 | + Int32 nUnused; |
| 100 | + void* unusedTmpV; |
| 101 | + UChar* unusedTmp; |
| 102 | ++ double fileSize = 0; /* initialized to make the compiler stop crying */ |
| 103 | ++ time_t startTime, currentTime; |
| 104 | + |
| 105 | + nUnused = 0; |
| 106 | + streamNo = 0; |
| 107 | +@@ -533,9 +568,19 @@ |
| 108 | + SET_BINARY_MODE(stream); |
| 109 | + SET_BINARY_MODE(zStream); |
| 110 | + |
| 111 | ++ if ((srcMode == SM_F2F || srcMode == SM_F2O) && showProgress == True) { |
| 112 | ++ off_t dummy = ftello(zStream); |
| 113 | ++ (void)fseeko(zStream, 0, SEEK_END); |
| 114 | ++ fileSize = ftello(zStream); |
| 115 | ++ (void)fseeko(zStream, dummy, SEEK_SET); |
| 116 | ++ if (verbosity >= 1) |
| 117 | ++ fprintf(stderr, "Input-file size: %ld\n", (long)fileSize); |
| 118 | ++ } |
| 119 | ++ |
| 120 | + if (ferror(stream)) goto errhandler_io; |
| 121 | + if (ferror(zStream)) goto errhandler_io; |
| 122 | + |
| 123 | ++ time(&startTime); |
| 124 | + while (True) { |
| 125 | + |
| 126 | + bzf = BZ2_bzReadOpen ( |
| 127 | +@@ -551,6 +596,16 @@ |
| 128 | + if ((bzerr == BZ_OK || bzerr == BZ_STREAM_END) && nread > 0) |
| 129 | + fwrite ( obuf, sizeof(UChar), nread, stream ); |
| 130 | + if (ferror(stream)) goto errhandler_io; |
| 131 | ++ |
| 132 | ++ if ((srcMode == SM_F2F || srcMode == SM_F2O) && showProgress == True) { |
| 133 | ++ time(¤tTime); |
| 134 | ++ if ((currentTime - startTime) >= 2) { |
| 135 | ++ double curInPos = ftello(zStream); |
| 136 | ++ startTime = currentTime; |
| 137 | ++ |
| 138 | ++ fprintf(stderr, "%.2f%% done\r", (curInPos * 100.0) / fileSize); |
| 139 | ++ } |
| 140 | ++ } |
| 141 | + } |
| 142 | + if (bzerr != BZ_STREAM_END) goto errhandler; |
| 143 | + |
| 144 | +@@ -1872,6 +1927,7 @@ |
| 145 | + deleteOutputOnInterrupt = False; |
| 146 | + exitValue = 0; |
| 147 | + i = j = 0; /* avoid bogus warning from egcs-1.1.X */ |
| 148 | ++ showProgress = False; |
| 149 | + |
| 150 | + /*-- Set up signal handlers for mem access errors --*/ |
| 151 | + signal (SIGSEGV, mySIGSEGVorSIGBUScatcher); |
| 152 | +@@ -1949,6 +2005,7 @@ |
| 153 | + case 'k': keepInputFiles = True; break; |
| 154 | + case 's': smallMode = True; break; |
| 155 | + case 'q': noisy = False; break; |
| 156 | ++ case 'p': showProgress = True; break; |
| 157 | + case '1': blockSize100k = 1; break; |
| 158 | + case '2': blockSize100k = 2; break; |
| 159 | + case '3': blockSize100k = 3; break; |
| 160 | +@@ -1985,6 +2042,7 @@ |
| 161 | + if (ISFLAG("--keep")) keepInputFiles = True; else |
| 162 | + if (ISFLAG("--small")) smallMode = True; else |
| 163 | + if (ISFLAG("--quiet")) noisy = False; else |
| 164 | ++ if (ISFLAG("--show-progress")) showProgress = True; else |
| 165 | + if (ISFLAG("--version")) license(); else |
| 166 | + if (ISFLAG("--license")) license(); else |
| 167 | + if (ISFLAG("--exponential")) workFactor = 1; else |
0 commit comments