[med-svn] [bedtools] 06/13: just peak at first bit in isGzipFile() fix for issue46

Charles Plessy plessy at moszumanska.debian.org
Fri Mar 21 07:23:47 UTC 2014


This is an automated email from the git hooks/post-receive script.

plessy pushed a commit to branch debian/unstable
in repository bedtools.

commit 6fbc3c26ae51f99b095b7675b631bf36fafbe2ea
Author: arq5x <arq5x at virginia.edu>
Date:   Thu Mar 20 11:50:13 2014 -0400

    just peak at first bit in isGzipFile() fix for issue46
---
 src/utils/fileType/fileType.cpp | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/utils/fileType/fileType.cpp b/src/utils/fileType/fileType.cpp
index 0b05acb..8589557 100644
--- a/src/utils/fileType/fileType.cpp
+++ b/src/utils/fileType/fileType.cpp
@@ -48,24 +48,31 @@ bool isGzipFile(istream *file) {
        without triggering the "fail" bit.  This was necessary to support
        FIFOs, per version 2.13.0
     */
-    struct  {
-        unsigned char id1;
+//    struct  {
+//        unsigned char id1;
 //      unsigned char id2;
 //      unsigned char cm;
-    } gzip_header;
+//    } gzip_header;
 
-    if (!file->read((char*)&gzip_header, sizeof(gzip_header))) {
-        return false;
-    }
-
-    if ( gzip_header.id1 == 0x1f )
+//   if (!file->read((char*)&gzip_header, sizeof(gzip_header))) {
+//       return false;
+//   }
+//  if ( gzip_header.id1 == 0x1f )
 //       &&
 //       gzip_header.id2 == 0x8b
 //       &&
 //       gzip_header.cm == 8 )
+
+/*
+        26-Dec-2012 and again 20-Mar-2014:
+        Just peek at the first byte instead of reading it so that we don't
+        affect the istream's failbit.  This modification was wisely proposed
+        by John Marshall in response to Issue 30:
+        https://github.com/arq5x/bedtools/issues/30
+ */
+    if (file->peek() != 0x1f)
     {
         return true;
     }
-    file->putback(gzip_header.id1);
     return false;
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/bedtools.git



More information about the debian-med-commit mailing list