Imported Upstream version 1.1.13 86/98686/1 upstream upstream/1.1.13 upstream/1.1.3
authorDongHun Kwak <dh0128.kwak@samsung.com>
Fri, 18 Nov 2016 07:46:41 +0000 (16:46 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Fri, 18 Nov 2016 07:46:41 +0000 (16:46 +0900)
Change-Id: Ifa54f95c2add6e98dd801cd5e2ae6e50a65fd6c4
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
COPYING
ChangeLog
Makefile
README
pbzip2.cpp
pbzip2.h
pbzip2.spec

diff --git a/COPYING b/COPYING
index 105bd9c..8a483b4 100644 (file)
--- a/COPYING
+++ b/COPYING
@@ -37,4 +37,4 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 Jeff Gilchrist, Ottawa, Canada.
 pbzip2@compression.ca
-pbzip2 version 1.1.12 of Dec 21, 2014
+pbzip2 version 1.1.13 of Dec 18, 2015
index 404ee6e..d2566ea 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Changes in 1.1.13 (Dec 18, 2015)
+- #1404812 add support for DESTDIR in Makefile (thanks to Ryan Schmidt)
+- #1429181 fix bad CYGWIN define (thanks to Marco Atzeri)
+- #1337949 rm unused vars; add hasInFile flag (thanks to Mingxing Zhang)
+- #1524909 - output sometimes truncated on redirected -cd
 Changes in 1.1.12 (Dec 21, 2014)
 - #1402154 - make relative symlinks on install (thanks to Evangelos Foutras)
 - Install manpages to share folder, thanks to Ryan Schmidt (#1402044)
index e570882..878439a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -60,6 +60,7 @@ LDLIBS += $(LDLIBS_PTHREAD)
 
 # Where you want pbzip2 installed when you do 'make install'
 PREFIX = /usr
+DESTDIR =
 
 
 all: pbzip2
@@ -74,16 +75,16 @@ pbzip2-static: pbzip2.cpp BZ2StreamScanner.cpp ErrorContext.cpp libbz2.a
 
 # Install the binary pbzip2 program and man page
 install: pbzip2
-       if ( test ! -d $(PREFIX)/bin ) ; then mkdir -p $(PREFIX)/bin ; fi
-       if ( test ! -d $(PREFIX)/share ) ; then mkdir -p $(PREFIX)/share ; fi
-       if ( test ! -d $(PREFIX)/share/man ) ; then mkdir -p $(PREFIX)/share/man ; fi
-       if ( test ! -d $(PREFIX)/share/man/man1 ) ; then mkdir -p $(PREFIX)/share/man/man1 ; fi
-       cp -f pbzip2 $(PREFIX)/bin/pbzip2
-       chmod a+x $(PREFIX)/bin/pbzip2
-       ln -s -f pbzip2 $(PREFIX)/bin/pbunzip2
-       ln -s -f pbzip2 $(PREFIX)/bin/pbzcat
-       cp -f pbzip2.1 $(PREFIX)/share/man/man1
-       chmod a+r $(PREFIX)/share/man/man1/pbzip2.1
+       if ( test ! -d $(DESTDIR)$(PREFIX)/bin ) ; then mkdir -p $(DESTDIR)$(PREFIX)/bin ; fi
+       if ( test ! -d $(DESTDIR)$(PREFIX)/share ) ; then mkdir -p $(DESTDIR)$(PREFIX)/share ; fi
+       if ( test ! -d $(DESTDIR)$(PREFIX)/share/man ) ; then mkdir -p $(DESTDIR)$(PREFIX)/share/man ; fi
+       if ( test ! -d $(DESTDIR)$(PREFIX)/share/man/man1 ) ; then mkdir -p $(DESTDIR)$(PREFIX)/share/man/man1 ; fi
+       cp -f pbzip2 $(DESTDIR)$(PREFIX)/bin/pbzip2
+       chmod a+x $(DESTDIR)$(PREFIX)/bin/pbzip2
+       ln -s -f pbzip2 $(DESTDIR)$(PREFIX)/bin/pbunzip2
+       ln -s -f pbzip2 $(DESTDIR)$(PREFIX)/bin/pbzcat
+       cp -f pbzip2.1 $(DESTDIR)$(PREFIX)/share/man/man1
+       chmod a+r $(DESTDIR)$(PREFIX)/share/man/man1/pbzip2.1
 
 clean:
        rm -f *.o pbzip2
diff --git a/README b/README
index 74d0625..f7fe81c 100644 (file)
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
-Dec 21, 2014
+Dec 18, 2015
 
-Parallel BZIP2 v1.1.10 - by: Jeff Gilchrist <pbzip2@compression.ca>
+Parallel BZIP2 v1.1.13 - by: Jeff Gilchrist <pbzip2@compression.ca>
 Available at:  http://compression.ca/
 
 This is the README for pbzip2, a parallel implementation of the
index 97996c1..66ca978 100644 (file)
@@ -44,7 +44,6 @@ static int finishedFlag = 0; // Main thread work finished (about to exit)
 static int unfinishedWorkCleaned = 0;
 static int numCPU = 2;
 static int IgnoreTrailingGarbageFlag = 0; // ingnore trailing garbage on decompress flag
-static int QUEUESIZE = 2;
 static int SIG_HANDLER_QUIT_SIGNAL = SIGUSR1; // signal used to stop SignalHandlerThread
 #ifdef USE_STACKSIZE_CUSTOMIZATION
 static int ChildThreadStackSize = 0; // -1 - don't modify stacksize; 0 - use minimum; > 0 - use specified
@@ -55,7 +54,6 @@ static int ChildThreadStackSize = 0; // -1 - don't modify stacksize; 0 - use min
 static unsigned char Bz2HeaderZero[] = {
        0x42, 0x5A, 0x68, 0x39, 0x17, 0x72, 0x45, 0x38, 0x50, 0x90, 0x00, 0x00, 0x00, 0x00 };
 static OFF_T InFileSize;
-static OFF_T InBytesProduced = 0;
 static int NumBlocks = 0;
 static int NumBlocksEstimated = 0;
 static int NumBufferedBlocks = 0;
@@ -1195,7 +1193,6 @@ int producerDecompressCheckInterrupt(int hInfile, outBuff *& fileData, int lastB
 int producer_decompress(int hInfile, OFF_T fileSize, queue *fifo)
 {
        safe_mutex_lock(&ProgressIndicatorsMutex);
-       InBytesProduced = 0;
        NumBlocks = 0;
        safe_mutex_unlock(&ProgressIndicatorsMutex);
        
@@ -1255,7 +1252,6 @@ int producer_decompress(int hInfile, OFF_T fileSize, queue *fifo)
                safe_cond_signal (fifo->notEmpty);
 
                safe_mutex_lock(&ProgressIndicatorsMutex);
-               InBytesProduced += fileData->bufSize;
                NumBlocks = fileData->blockNumber + 1;
                safe_mutex_unlock(&ProgressIndicatorsMutex);
 
@@ -2083,6 +2079,21 @@ int directcompress(int hInfile, OFF_T fileSize, int blockSize, const char *OutFi
        return 0;
 }
 
+void close_streams(FILE *out, FILE *in)
+{
+       if (out != NULL) {
+               fflush(out);
+       }
+
+       if (in != NULL && in != stdin) {
+               fclose(in);
+       }
+
+       if (out != NULL && out != stdout) {
+               fclose(out);
+       }
+}
+
 /*
  *********************************************************
  */
@@ -2125,9 +2136,7 @@ int directdecompress(const char *InFilename, const char *OutFilename)
        // check file stream for errors
        if (ferror(zStream))
        {
-               if (zStream != stdin)
-                       fclose(zStream);
-
+               close_streams(stream, zStream);
                handle_error(EF_EXIT, -1,
                                "pbzip2: *ERROR: Problem with input stream of file [%s]!  Aborting...\n", InFilename);
                return -1;
@@ -2155,9 +2164,7 @@ int directdecompress(const char *InFilename, const char *OutFilename)
        // check file stream for errors
        if (ferror(stream))
        {
-               if (stream != stdout)
-                       fclose(stream);
-               
+               close_streams(stream, zStream);
                handle_error(EF_EXIT, -1,
                                "pbzip2: *ERROR: Problem with output stream of file [%s]!  Aborting...\n", InFilename);
                return -1;
@@ -2169,10 +2176,7 @@ int directdecompress(const char *InFilename, const char *OutFilename)
                if (syncGetTerminateFlag() != 0)
                {
                        fprintf (stderr, "directdecompress: terminating1 - terminateFlag set\n");
-                       if (zStream != stdin)
-                               fclose(zStream);
-                       if (stream != stdout)
-                               fclose(stream);
+                       close_streams(stream, zStream);
                        return -1;
                }
 
@@ -2180,11 +2184,8 @@ int directdecompress(const char *InFilename, const char *OutFilename)
                if (bzf == NULL || bzerr != BZ_OK)
                {
                        ret = testBZ2ErrorHandling(bzerr, bzf, streamNo);
-                       if (zStream != stdin)
-                               fclose(zStream);
-                       if (stream != stdout)
-                               fclose(stream);
-                       
+                       close_streams(stream, zStream);
+       
                        if (ret != 0)
                        {
                                syncSetTerminateFlag(1);
@@ -2200,10 +2201,7 @@ int directdecompress(const char *InFilename, const char *OutFilename)
                        if (syncGetTerminateFlag() != 0)
                        {
                                fprintf (stderr, "directdecompress: terminating2 - terminateFlag set\n");
-                               if (zStream != stdin)
-                                       fclose(zStream);
-                               if (stream != stdout)
-                                       fclose(stream);
+                               close_streams(stream, zStream);
                                return -1;
                        }
 
@@ -2225,11 +2223,8 @@ int directdecompress(const char *InFilename, const char *OutFilename)
                                                if (ferror(zStream))
                                                {
                                                        ret = testBZ2ErrorHandling(bzerr, bzf, streamNo);
-                                                       if (zStream != stdin)
-                                                               fclose(zStream);
-                                                       if (stream != stdout)
-                                                               fclose(stream);
-                                                       
+                                                       close_streams(stream, zStream);
+
                                                        if (ret != 0)
                                                        {
                                                                syncSetTerminateFlag(1);
@@ -2242,11 +2237,8 @@ int directdecompress(const char *InFilename, const char *OutFilename)
                                                if (ferror(stream))
                                                {
                                                        ret = testBZ2ErrorHandling(bzerr, bzf, streamNo);
-                                                       if (zStream != stdin)
-                                                               fclose(zStream);
-                                                       if (stream != stdout)
-                                                               fclose(stream);
-                                                       
+                                                       close_streams(stream, zStream);
+
                                                        if (ret != 0)
                                                        {
                                                                syncSetTerminateFlag(1);
@@ -2263,11 +2255,8 @@ int directdecompress(const char *InFilename, const char *OutFilename)
                        if (ferror(stream))
                        {
                                ret = testBZ2ErrorHandling(bzerr, bzf, streamNo);
-                               if (zStream != stdin)
-                                       fclose(zStream);
-                               if (stream != stdout)
-                                       fclose(stream);
-                               
+                               close_streams(stream, zStream);
+
                                if (ret != 0)
                                {
                                        syncSetTerminateFlag(1);
@@ -2278,11 +2267,8 @@ int directdecompress(const char *InFilename, const char *OutFilename)
                if (bzerr != BZ_STREAM_END)
                {
                        ret = testBZ2ErrorHandling(bzerr, bzf, streamNo);
-                       if (zStream != stdin)
-                               fclose(zStream);
-                       if (stream != stdout)
-                               fclose(stream);
-                       
+                       close_streams(stream, zStream);
+
                        if (ret != 0)
                        {
                                syncSetTerminateFlag(1);
@@ -2416,7 +2402,6 @@ int producer(int hInfile, int blockSize, queue *fifo)
 
        safe_mutex_lock(&ProgressIndicatorsMutex);
        NumBlocks = 0;
-       InBytesProduced = 0;
        safe_mutex_unlock(&ProgressIndicatorsMutex);
 
        // keep going until all the file is processed
@@ -2510,7 +2495,6 @@ int producer(int hInfile, int blockSize, queue *fifo)
 
                safe_mutex_lock(&ProgressIndicatorsMutex);
                ++NumBlocks;
-               InBytesProduced += inSize;
                safe_mutex_unlock(&ProgressIndicatorsMutex);
                
                safe_mutex_unlock(fifo->mut);
@@ -2692,7 +2676,6 @@ void mutexesDelete()
 queue *queueInit(int queueSize)
 {
        queue *q;
-       QUEUESIZE = queueSize;
 
        q = new(std::nothrow) queue;
        if (q == NULL)
@@ -3224,7 +3207,7 @@ int detectCPUs()
  */
 void banner()
 {
-       fprintf(stderr, "Parallel BZIP2 v1.1.12 [Dec 21, 2014]\n");
+       fprintf(stderr, "Parallel BZIP2 v1.1.13 [Dec 18, 2015]\n");
        fprintf(stderr, "By: Jeff Gilchrist [http://compression.ca]\n");
        fprintf(stderr, "Major contributions: Yavor Nikolov [http://javornikolov.wordpress.com]\n");
        fprintf(stderr, "Uses libbzip2 by Julian Seward\n");
@@ -3298,6 +3281,7 @@ int main(int argc, char* argv[])
        pthread_t output;
        char **FileList = NULL;
        char *InFilename = NULL;
+       bool hasInFile = false;
        char *progName = NULL;
        char *progNamePos = NULL;
        char bz2Header[] = {"BZh91AY&SY"};  // using 900k block size
@@ -3870,6 +3854,7 @@ int main(int argc, char* argv[])
 
                // set input filename
                InFilename = FileList[fileLoop];
+               hasInFile = (strcmp(InFilename, "-") != 0);
 
                // test file for errors if requested
                if (testFile != 0)
@@ -3877,7 +3862,7 @@ int main(int argc, char* argv[])
                        if (QuietMode != 1)
                        {
                                fprintf(stderr, "      File #: %d of %d\n", fileLoop+1, FileListCount);
-                               if (strcmp(InFilename, "-") != 0) 
+                               if (hasInFile)
                                        fprintf(stderr, "     Testing: %s\n", InFilename);
                                else
                                        fprintf(stderr, "     Testing: <stdin>\n");
@@ -3900,7 +3885,7 @@ int main(int argc, char* argv[])
 
                // set ouput filename
                outFilename = std::string(FileList[fileLoop]);
-               if ((decompress == 1) && (strcmp(InFilename, "-") != 0))
+               if ((decompress == 1) && hasInFile)
                {
                        // check if input file is a valid .bz2 compressed file
                        hInfile = open(InFilename, O_RDONLY | O_BINARY);
@@ -4000,7 +3985,7 @@ int main(int argc, char* argv[])
                sigOutFilename = outFilename.c_str();
                safe_mutex_unlock(&ErrorHandlerMutex);
 
-               if (strcmp(InFilename, "-") != 0) 
+               if (hasInFile)
                {
                        struct stat statbuf;
                        // read file for compression
@@ -4116,7 +4101,7 @@ int main(int argc, char* argv[])
 
                        if (decompress == 1)
                                fprintf(stderr, " BWT Block Size: %c00k\n", BWTblockSizeChar);
-                       if (strcmp(InFilename, "-") != 0) 
+                       if (hasInFile)
                                fprintf(stderr, "     Input Size: %"PRIuMAX" bytes\n", (uintmax_t)InFileSize);
                }
 
@@ -4130,7 +4115,7 @@ int main(int argc, char* argv[])
                                noThreads = 0;
                        
                        // Enable threads method for uncompressing from stdin
-                       if ((numCPU > 1) && (strcmp(InFilename, "-") == 0))
+                       if ((numCPU > 1) && !hasInFile)
                                noThreads = 0;
                } // if (decompress == 1)
                else
index e9d62c0..6d4bf11 100644 (file)
--- a/pbzip2.h
+++ b/pbzip2.h
@@ -68,7 +68,7 @@ extern "C"
 //#define PBZIP_NO_LOADAVG
 
 // detect systems that are known not to support load average code
-#if defined (WIN32) || defined (__CYGWIN32__) || defined (__MINGW32__) || defined (__BORLANDC__) || defined (__hpux) || defined (__osf__) || defined(__UCLIBC__)
+#if defined (WIN32) || defined (__CYGWIN__) || defined (__MINGW32__) || defined (__BORLANDC__) || defined (__hpux) || defined (__osf__) || defined(__UCLIBC__)
        #define PBZIP_NO_LOADAVG
 #endif
 
index 86c11b9..2241065 100644 (file)
@@ -53,6 +53,9 @@ rm -rf %{buildroot}
 
 
 %changelog
+* Fri Dec 18 2015 Jeff Gilchrist <pbzip2@compression.ca> - 1.1.13-1
+- Release 1.1.13
+
 * Sun Dec 21 2014 Jeff Gilchrist <pbzip2@compression.ca> - 1.1.12-1
 - Release 1.1.12