Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 82192 | Differences between
and this patch

Collapse All | Expand All

(-)bzip2-1.0.2.org/bzip2.1 (+4 lines)
Lines 235-240 Link Here
235
Suppress non-essential warning messages.  Messages pertaining to
235
Suppress non-essential warning messages.  Messages pertaining to
236
I/O errors and other critical events will not be suppressed.
236
I/O errors and other critical events will not be suppressed.
237
.TP
237
.TP
238
.B \-p --show-progress
239
Show percentage of input-file done and while compressing show the percentage
240
of the original file the new file is.
241
.TP
238
.B \-v --verbose
242
.B \-v --verbose
239
Verbose mode -- show the compression ratio for each file processed.
243
Verbose mode -- show the compression ratio for each file processed.
240
Further \-v's increase the verbosity level, spewing out lots of
244
Further \-v's increase the verbosity level, spewing out lots of
(-)bzip2-1.0.2.org/bzip2.c (-1 / +63 lines)
Lines 145-150 Link Here
145
#include <signal.h>
145
#include <signal.h>
146
#include <math.h>
146
#include <math.h>
147
#include <errno.h>
147
#include <errno.h>
148
#include <time.h>
148
#include <ctype.h>
149
#include <ctype.h>
149
#include "bzlib.h"
150
#include "bzlib.h"
150
151
Lines 301-306 Link Here
301
Char    progNameReally[FILE_NAME_LEN];
302
Char    progNameReally[FILE_NAME_LEN];
302
FILE    *outputHandleJustInCase;
303
FILE    *outputHandleJustInCase;
303
Int32   workFactor;
304
Int32   workFactor;
305
Char	showProgress;
304
306
305
static void    panic                 ( Char* )   NORETURN;
307
static void    panic                 ( Char* )   NORETURN;
306
static void    ioError               ( void )    NORETURN;
308
static void    ioError               ( void )    NORETURN;
Lines 425-430 Link Here
425
   UInt32  nbytes_in_lo32, nbytes_in_hi32;
427
   UInt32  nbytes_in_lo32, nbytes_in_hi32;
426
   UInt32  nbytes_out_lo32, nbytes_out_hi32;
428
   UInt32  nbytes_out_lo32, nbytes_out_hi32;
427
   Int32   bzerr, bzerr_dummy, ret;
429
   Int32   bzerr, bzerr_dummy, ret;
430
   double  fileSize = 0; /* initialized to make the compiler stop crying */
431
                         /* double because big files might otherwhise give
432
                          * overflows. not long long since not all compilers
433
                          * support that one
434
                          */
435
   time_t  startTime, currentTime;
428
436
429
   SET_BINARY_MODE(stream);
437
   SET_BINARY_MODE(stream);
430
   SET_BINARY_MODE(zStream);
438
   SET_BINARY_MODE(zStream);
Lines 432-443 Link Here
432
   if (ferror(stream)) goto errhandler_io;
440
   if (ferror(stream)) goto errhandler_io;
433
   if (ferror(zStream)) goto errhandler_io;
441
   if (ferror(zStream)) goto errhandler_io;
434
442
443
   if ((srcMode == SM_F2F || srcMode == SM_F2O) && showProgress == True) {
444
      (void)fseek(stream, 0, SEEK_END);
445
      fileSize = (double)ftell(stream);
446
      rewind(stream);
447
      if (verbosity >= 1)
448
         fprintf(stderr, "Input-file size: %ld\n", (long)fileSize);
449
   }
450
435
   bzf = BZ2_bzWriteOpen ( &bzerr, zStream, 
451
   bzf = BZ2_bzWriteOpen ( &bzerr, zStream, 
436
                           blockSize100k, verbosity, workFactor );   
452
                           blockSize100k, verbosity, workFactor );   
437
   if (bzerr != BZ_OK) goto errhandler;
453
   if (bzerr != BZ_OK) goto errhandler;
438
454
439
   if (verbosity >= 2) fprintf ( stderr, "\n" );
455
   if (verbosity >= 2) fprintf ( stderr, "\n" );
440
456
457
   time(&startTime);
441
   while (True) {
458
   while (True) {
442
459
443
      if (myfeof(stream)) break;
460
      if (myfeof(stream)) break;
Lines 446-458 Link Here
446
      if (nIbuf > 0) BZ2_bzWrite ( &bzerr, bzf, (void*)ibuf, nIbuf );
463
      if (nIbuf > 0) BZ2_bzWrite ( &bzerr, bzf, (void*)ibuf, nIbuf );
447
      if (bzerr != BZ_OK) goto errhandler;
464
      if (bzerr != BZ_OK) goto errhandler;
448
465
466
      if ((srcMode == SM_F2F || srcMode == SM_F2O) && showProgress == True)
467
      {
468
         time(&currentTime);
469
470
         if ((currentTime - startTime) > 1) { /* show progress every 2 seconds */
471
            double curInPos = (double)ftell(stream);
472
            double curOutPos = (double)ftell(zStream);
473
474
            startTime = currentTime;
475
476
            fprintf(stderr, "%.2f%% done", (curInPos * 100.0) / fileSize);
477
            if (srcMode == SM_F2F)
478
            {
479
               fprintf(stderr, ", new size: %.2f%%", (curOutPos * 100.0) / curInPos);
480
            }
481
482
            fprintf(stderr, "    \r");
483
         }
484
      }
449
   }
485
   }
450
486
451
   BZ2_bzWriteClose64 ( &bzerr, bzf, 0, 
487
   BZ2_bzWriteClose64 ( &bzerr, bzf, 0, 
452
                        &nbytes_in_lo32, &nbytes_in_hi32,
488
                        &nbytes_in_lo32, &nbytes_in_hi32,
453
                        &nbytes_out_lo32, &nbytes_out_hi32 );
489
                        &nbytes_out_lo32, &nbytes_out_hi32 );
454
   if (bzerr != BZ_OK) goto errhandler;
490
   if (bzerr != BZ_OK) goto errhandler;
455
491
   
456
   if (ferror(zStream)) goto errhandler_io;
492
   if (ferror(zStream)) goto errhandler_io;
457
   ret = fflush ( zStream );
493
   ret = fflush ( zStream );
458
   if (ret == EOF) goto errhandler_io;
494
   if (ret == EOF) goto errhandler_io;
Lines 526-531 Link Here
526
   UChar   unused[BZ_MAX_UNUSED];
562
   UChar   unused[BZ_MAX_UNUSED];
527
   Int32   nUnused;
563
   Int32   nUnused;
528
   UChar*  unusedTmp;
564
   UChar*  unusedTmp;
565
   double  fileSize = 0; /* initialized to make the compiler stop crying */
566
   time_t  startTime, currentTime;
529
567
530
   nUnused = 0;
568
   nUnused = 0;
531
   streamNo = 0;
569
   streamNo = 0;
Lines 533-541 Link Here
533
   SET_BINARY_MODE(stream);
571
   SET_BINARY_MODE(stream);
534
   SET_BINARY_MODE(zStream);
572
   SET_BINARY_MODE(zStream);
535
573
574
   if ((srcMode == SM_F2F || srcMode == SM_F2O) && showProgress == True) {
575
      long dummy = ftell(zStream);
576
      (void)fseek(zStream, 0, SEEK_END);
577
      fileSize = (double)ftell(zStream);
578
      (void)fseek(zStream, dummy, SEEK_SET);
579
      if (verbosity >= 1)
580
         fprintf(stderr, "Input-file size: %ld\n", (long)fileSize);
581
   }
582
536
   if (ferror(stream)) goto errhandler_io;
583
   if (ferror(stream)) goto errhandler_io;
537
   if (ferror(zStream)) goto errhandler_io;
584
   if (ferror(zStream)) goto errhandler_io;
538
585
586
   time(&startTime);
539
   while (True) {
587
   while (True) {
540
588
541
      bzf = BZ2_bzReadOpen ( 
589
      bzf = BZ2_bzReadOpen ( 
Lines 551-556 Link Here
551
         if ((bzerr == BZ_OK || bzerr == BZ_STREAM_END) && nread > 0)
599
         if ((bzerr == BZ_OK || bzerr == BZ_STREAM_END) && nread > 0)
552
            fwrite ( obuf, sizeof(UChar), nread, stream );
600
            fwrite ( obuf, sizeof(UChar), nread, stream );
553
         if (ferror(stream)) goto errhandler_io;
601
         if (ferror(stream)) goto errhandler_io;
602
603
         if ((srcMode == SM_F2F || srcMode == SM_F2O) && showProgress == True) {
604
            time(&currentTime);
605
            if ((currentTime - startTime) >= 2)
606
            {
607
               double curInPos = (double)ftell(zStream);
608
               startTime = currentTime;
609
610
               fprintf(stderr, "%.2f%% done\r", (curInPos * 100.0) / fileSize);
611
            }
612
         }
554
      }
613
      }
555
      if (bzerr != BZ_STREAM_END) goto errhandler;
614
      if (bzerr != BZ_STREAM_END) goto errhandler;
556
615
Lines 1872-1877 Link Here
1872
   deleteOutputOnInterrupt = False;
1931
   deleteOutputOnInterrupt = False;
1873
   exitValue               = 0;
1932
   exitValue               = 0;
1874
   i = j = 0; /* avoid bogus warning from egcs-1.1.X */
1933
   i = j = 0; /* avoid bogus warning from egcs-1.1.X */
1934
   showProgress            = False;
1875
1935
1876
   /*-- Set up signal handlers for mem access errors --*/
1936
   /*-- Set up signal handlers for mem access errors --*/
1877
   signal (SIGSEGV, mySIGSEGVorSIGBUScatcher);
1937
   signal (SIGSEGV, mySIGSEGVorSIGBUScatcher);
Lines 1949-1954 Link Here
1949
               case 'k': keepInputFiles   = True; break;
2009
               case 'k': keepInputFiles   = True; break;
1950
               case 's': smallMode        = True; break;
2010
               case 's': smallMode        = True; break;
1951
               case 'q': noisy            = False; break;
2011
               case 'q': noisy            = False; break;
2012
               case 'p': showProgress     = True; break;
1952
               case '1': blockSize100k    = 1; break;
2013
               case '1': blockSize100k    = 1; break;
1953
               case '2': blockSize100k    = 2; break;
2014
               case '2': blockSize100k    = 2; break;
1954
               case '3': blockSize100k    = 3; break;
2015
               case '3': blockSize100k    = 3; break;
Lines 1985-1990 Link Here
1985
      if (ISFLAG("--keep"))              keepInputFiles   = True;    else
2046
      if (ISFLAG("--keep"))              keepInputFiles   = True;    else
1986
      if (ISFLAG("--small"))             smallMode        = True;    else
2047
      if (ISFLAG("--small"))             smallMode        = True;    else
1987
      if (ISFLAG("--quiet"))             noisy            = False;   else
2048
      if (ISFLAG("--quiet"))             noisy            = False;   else
2049
      if (ISFLAG("--show-progress"))     showProgress     = True;    else
1988
      if (ISFLAG("--version"))           license();                  else
2050
      if (ISFLAG("--version"))           license();                  else
1989
      if (ISFLAG("--license"))           license();                  else
2051
      if (ISFLAG("--license"))           license();                  else
1990
      if (ISFLAG("--exponential"))       workFactor = 1;             else 
2052
      if (ISFLAG("--exponential"))       workFactor = 1;             else 

Return to bug 82192