1 diff -uNr bzip2-1.0.2.org/bzip2.1 bzip2-1.0.2/bzip2.1
2 --- bzip2-1.0.2.org/doc/bzip2.1 Thu Jan 3 00:14:36 2002
3 +++ bzip2-1.0.2/doc/bzip2.1 Mon Jan 20 19:57:40 2003
5 Suppress non-essential warning messages. Messages pertaining to
6 I/O errors and other critical events will not be suppressed.
8 +.B \-p --show-progress
9 +Show percentage of input-file done and while compressing show the percentage
10 +of the original file the new file is.
13 Verbose mode -- show the compression ratio for each file processed.
14 Further \-v's increase the verbosity level, spewing out lots of
15 diff -uNr bzip2-1.0.2.org/bzip2.c bzip2-1.0.2/bzip2.c
16 --- bzip2-1.0.2.org/bzip2.c Fri Jan 25 02:38:36 2002
17 +++ bzip2-1.0.2/bzip2.c Mon Jan 20 19:55:29 2003
27 Char progNameReally[FILE_NAME_LEN];
28 FILE *outputHandleJustInCase;
32 static void panic ( Char* ) NORETURN;
33 static void ioError ( void ) NORETURN;
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
43 + time_t startTime, currentTime;
45 SET_BINARY_MODE(stream);
46 SET_BINARY_MODE(zStream);
48 if (ferror(stream)) goto errhandler_io;
49 if (ferror(zStream)) goto errhandler_io;
51 + if ((srcMode == SM_F2F || srcMode == SM_F2O) && showProgress == True) {
52 + (void)fseek(stream, 0, SEEK_END);
53 + fileSize = (double)ftell(stream);
56 + fprintf(stderr, "Input-file size: %ld\n", (long)fileSize);
59 bzf = BZ2_bzWriteOpen ( &bzerr, zStream,
60 blockSize100k, verbosity, workFactor );
61 if (bzerr != BZ_OK) goto errhandler;
63 if (verbosity >= 2) fprintf ( stderr, "\n" );
68 if (myfeof(stream)) break;
70 if (nIbuf > 0) BZ2_bzWrite ( &bzerr, bzf, (void*)ibuf, nIbuf );
71 if (bzerr != BZ_OK) goto errhandler;
73 + if ((srcMode == SM_F2F || srcMode == SM_F2O) && showProgress == True)
77 + if ((currentTime - startTime) > 1) { /* show progress every 2 seconds */
78 + double curInPos = (double)ftell(stream);
79 + double curOutPos = (double)ftell(zStream);
81 + startTime = currentTime;
83 + fprintf(stderr, "%.2f%% done", (curInPos * 100.0) / fileSize);
84 + if (srcMode == SM_F2F)
86 + fprintf(stderr, ", new size: %.2f%%", (curOutPos * 100.0) / curInPos);
89 + fprintf(stderr, " \r");
94 BZ2_bzWriteClose64 ( &bzerr, bzf, 0,
95 &nbytes_in_lo32, &nbytes_in_hi32,
96 &nbytes_out_lo32, &nbytes_out_hi32 );
97 if (bzerr != BZ_OK) goto errhandler;
100 if (ferror(zStream)) goto errhandler_io;
101 ret = fflush ( zStream );
102 if (ret == EOF) goto errhandler_io;
104 UChar unused[BZ_MAX_UNUSED];
107 + double fileSize = 0; /* initialized to make the compiler stop crying */
108 + time_t startTime, currentTime;
113 SET_BINARY_MODE(stream);
114 SET_BINARY_MODE(zStream);
116 + if ((srcMode == SM_F2F || srcMode == SM_F2O) && showProgress == True) {
117 + long dummy = ftell(zStream);
118 + (void)fseek(zStream, 0, SEEK_END);
119 + fileSize = (double)ftell(zStream);
120 + (void)fseek(zStream, dummy, SEEK_SET);
121 + if (verbosity >= 1)
122 + fprintf(stderr, "Input-file size: %ld\n", (long)fileSize);
125 if (ferror(stream)) goto errhandler_io;
126 if (ferror(zStream)) goto errhandler_io;
131 bzf = BZ2_bzReadOpen (
133 if ((bzerr == BZ_OK || bzerr == BZ_STREAM_END) && nread > 0)
134 fwrite ( obuf, sizeof(UChar), nread, stream );
135 if (ferror(stream)) goto errhandler_io;
137 + if ((srcMode == SM_F2F || srcMode == SM_F2O) && showProgress == True) {
138 + time(¤tTime);
139 + if ((currentTime - startTime) >= 2)
141 + double curInPos = (double)ftell(zStream);
142 + startTime = currentTime;
144 + fprintf(stderr, "%.2f%% done\r", (curInPos * 100.0) / fileSize);
148 if (bzerr != BZ_STREAM_END) goto errhandler;
150 @@ -1872,6 +1931,7 @@
151 deleteOutputOnInterrupt = False;
153 i = j = 0; /* avoid bogus warning from egcs-1.1.X */
154 + showProgress = False;
156 /*-- Set up signal handlers for mem access errors --*/
157 signal (SIGSEGV, mySIGSEGVorSIGBUScatcher);
158 @@ -1949,6 +2009,7 @@
159 case 'k': keepInputFiles = True; break;
160 case 's': smallMode = True; break;
161 case 'q': noisy = False; break;
162 + case 'p': showProgress = True; break;
163 case '1': blockSize100k = 1; break;
164 case '2': blockSize100k = 2; break;
165 case '3': blockSize100k = 3; break;
166 @@ -1985,6 +2046,7 @@
167 if (ISFLAG("--keep")) keepInputFiles = True; else
168 if (ISFLAG("--small")) smallMode = True; else
169 if (ISFLAG("--quiet")) noisy = False; else
170 + if (ISFLAG("--show-progress")) showProgress = True; else
171 if (ISFLAG("--version")) license(); else
172 if (ISFLAG("--license")) license(); else
173 if (ISFLAG("--exponential")) workFactor = 1; else
174 @@ -2014,6 +2076,10 @@
176 if (srcMode == SM_F2O && numFileNames == 0)
179 + if (srcMode != SM_F2F && srcMode != SM_F2O) {
180 + fprintf ( stderr, "progress will only be shown when compressing files.\n");
183 if (opMode != OM_Z) blockSize100k = 0;