On 1/18/2010 23:32, Antonio Diaz Diaz wrote:
I am pleased to announce the release of lzip 1.9.

Lzip is a lossless data compressor based on the LZMA algorithm, with
very safe integrity checking and a user interface similar to the one of
gzip or bzip2. Lzip decompresses almost as fast as gzip and compresses
better than bzip2, which makes it well suited for software distribution
and data archiving.


Hi,

here is the win32 patch updated for 1.9. "make check" runs cleanly.
diff --git a/Makefile.in b/Makefile.in
index 09b0294..87c0593 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -30,7 +30,7 @@ main.o : main.cc
 lziprecover.o : lziprecover.cc
        $(CXX) $(CPPFLAGS) $(CXXFLAGS) -DPROGVERSION=\"$(pkgversion)\" -c -o $@ 
$<
 
-%.o : %.cc
+%.o : %.cc lzip_compat.h
        $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
 
 $(objs)       : Makefile
diff --git a/decoder.cc b/decoder.cc
index 4e3a8fc..3afbe49 100755
--- a/decoder.cc
+++ b/decoder.cc
@@ -1,5 +1,6 @@
 /*  Lzip - A data compressor based on the LZMA algorithm
     Copyright (C) 2008, 2009, 2010 Antonio Diaz Diaz.
+    Patched for MinGW by Jonatan Yong <jon_y [a] users.sourceforge.net>.
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -16,6 +17,7 @@
 */
 
 #define _FILE_OFFSET_BITS 64
+#define __STDC_FORMAT_MACROS
 
 #include <algorithm>
 #include <cerrno>
@@ -24,7 +26,7 @@
 #include <cstring>
 #include <string>
 #include <vector>
-#include <stdint.h>
+#include <inttypes.h>
 
 #include "lzip.h"
 #include "decoder.h"
@@ -106,7 +108,7 @@ bool LZ_decoder::verify_trailer( const Pretty_print & pp ) 
const
       {
       if( trailer.data_size() >= 0 )
         { pp();
-          std::fprintf( stderr, "data size mismatch; trailer says %lld, data 
size is %lld.\n",
+          std::fprintf( stderr, "data size mismatch; trailer says %"PRId64", 
data size is %"PRId64".\n",
                         trailer.data_size(), data_position() ); }
       else pp( "member trailer is corrupt" );
       }
@@ -118,13 +120,13 @@ bool LZ_decoder::verify_trailer( const Pretty_print & pp 
) const
       {
       if( trailer.member_size() >= 0 )
         { pp();
-          std::fprintf( stderr, "member size mismatch; trailer says %lld, 
member size is %lld.\n",
+          std::fprintf( stderr, "member size mismatch; trailer says %"PRId64", 
member size is %"PRId64".\n",
                         trailer.member_size(), member_position() ); }
       else pp( "member trailer is corrupt" );
       }
     }
   if( !error && verbosity >= 3 )
-    std::fprintf( stderr, "data crc %08X, data size %9lld, member size %8lld.  
",
+    std::fprintf( stderr, "data crc %08X, data size %9"PRId64", member size 
%8"PRId64".  ",
                   (unsigned int)trailer.data_crc(), trailer.data_size(),
                   trailer.member_size() );
   return !error;
diff --git a/lzip_compat.h b/lzip_compat.h
new file mode 100644
index 0000000..b488029
--- /dev/null
+++ b/lzip_compat.h
@@ -0,0 +1,57 @@
+/*  lzip_compat.h - Systems compatibility header
+    Copyright (C) 2009 Jonathan Yong.
+    
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef _FILE_OFFSET_BITS
+#define _FILE_OFFSET_BITS 64
+#endif
+
+#ifdef __MSVCRT__ /* Using Windows MSVCRT.DLL */
+/* We don't care about permissions */
+#define S_IRGRP _S_IREAD
+#define S_IROTH _S_IREAD
+#define S_IRGRP _S_IREAD
+#define S_IROTH _S_IREAD
+
+/* Windows doesn't have sighup, neither is it needed. */
+#define SIGHUP SIGBREAK
+
+/* Unimplemented Functions */
+#define fchmod(x,y) 0
+#define fchown(x,y,z) 0
+#define S_ISSOCK(x) 0
+
+/* Inline compat wrappers */
+#define compat_wrap(x) compat_msvcrt_##x
+#else
+#define compat_wrap(x) x
+#endif
+
+#ifdef __MSVCRT__
+/* These will only be used for MSVCR based runtime */
+static inline int compat_msvcrt_read( int fildes, void *buf, size_t nbyte )
+{
+  /*Set IO mode to Binary */
+  _setmode(  fildes, _O_BINARY );
+  return read( fildes, buf, nbyte );
+}
+
+static inline int compat_msvcrt_write( int fildes, const void *buf, size_t 
nbyte )
+{
+  /*Set IO mode to Binary */
+  _setmode(  fildes, _O_BINARY );
+  return write( fildes, buf, nbyte );
+}
+#endif
diff --git a/lziprecover.cc b/lziprecover.cc
index dda4b5e..79e33bb 100755
--- a/lziprecover.cc
+++ b/lziprecover.cc
@@ -1,5 +1,6 @@
 /*  Lziprecover - Member recoverer program for lzip compressed files
     Copyright (C) 2008, 2009, 2010 Antonio Diaz Diaz.
+    Patched for MinGW by Jonatan Yong <jon_y [a] users.sourceforge.net>.
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -22,6 +23,7 @@
 */
 
 #define _FILE_OFFSET_BITS 64
+#define __STDC_FORMAT_MACROS
 
 #include <cerrno>
 #include <cstdio>
@@ -36,7 +38,7 @@
 
 #include "arg_parser.h"
 #include "lzip.h"
-
+#include "lzip_compat.h"
 
 namespace {
 
@@ -282,7 +284,7 @@ int readblock( const int fd, char * buf, const int size ) 
throw()
   while( rest > 0 )
     {
     errno = 0;
-    const int n = read( fd, buf + size - rest, rest );
+    const int n = compat_wrap( read( fd, buf + size - rest, rest ));
     if( n > 0 ) rest -= n;
     else if( n == 0 ) break;
     else if( errno != EINTR && errno != EAGAIN ) break;
@@ -301,7 +303,7 @@ int writeblock( const int fd, const char * buf, const int 
size ) throw()
   while( rest > 0 )
     {
     errno = 0;
-    const int n = write( fd, buf + size - rest, rest );
+    const int n = compat_wrap( write( fd, buf + size - rest, rest ));
     if( n > 0 ) rest -= n;
     else if( errno && errno != EINTR && errno != EAGAIN ) break;
     }
diff --git a/main.cc b/main.cc
index 1f12805..bef5f55 100755
--- a/main.cc
+++ b/main.cc
@@ -1,5 +1,6 @@
 /*  Lzip - A data compressor based on the LZMA algorithm
     Copyright (C) 2008, 2009, 2010 Antonio Diaz Diaz.
+    Patched for MinGW by Jonatan Yong <jon_y [a] users.sourceforge.net>.
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -22,6 +23,7 @@
 */
 
 #define _FILE_OFFSET_BITS 64
+#define __STDC_FORMAT_MACROS
 
 #include <algorithm>
 #include <cerrno>
@@ -33,7 +35,7 @@
 #include <string>
 #include <vector>
 #include <fcntl.h>
-#include <stdint.h>
+#include <inttypes.h>
 #include <unistd.h>
 #include <utime.h>
 #include <sys/stat.h>
@@ -43,6 +45,7 @@
 #include "lzip.h"
 #include "decoder.h"
 #include "encoder.h"
+#include "lzip_compat.h"
 
 #ifndef LLONG_MAX
 #define LLONG_MAX  0x7FFFFFFFFFFFFFFFLL
@@ -140,7 +143,7 @@ const char * format_num( long long num, long long limit = 
9999,
   for( int i = 0; i < 8 && ( llabs( num ) > limit ||
        ( llabs( num ) >= factor && num % factor == 0 ) ); ++i )
     { num /= factor; p = prefix[i]; }
-  snprintf( buf, sizeof buf, "%lld %s", num, p );
+  snprintf( buf, sizeof buf, "%"PRId64" %s", num, p );
   return buf;
   }
 
@@ -444,7 +447,7 @@ int compress( const long long member_size, const long long 
volume_size,
         std::fprintf( stderr, "no data compressed.\n" );
       else
         std::fprintf( stderr, "%6.3f:1, %6.3f bits/byte, "
-                              "%5.2f%% saved, %lld in, %lld out.\n",
+                              "%5.2f%% saved, %"PRId64" in, %"PRId64" out.\n",
                       (double)in_size / out_size,
                       ( 8.0 * out_size ) / in_size,
                       100.0 * ( 1.0 - ( (double)out_size / in_size ) ),
@@ -516,10 +519,10 @@ int decompress( const int inhandle, const Pretty_print & 
pp,
           {
           pp();
           if( result == 2 )
-            std::fprintf( stderr, "file ends unexpectedly at pos %lld\n",
+            std::fprintf( stderr, "file ends unexpectedly at pos %"PRId64"\n",
                           partial_file_pos );
           else
-            std::fprintf( stderr, "decoder error at pos %lld\n",
+            std::fprintf( stderr, "decoder error at pos %"PRId64"\n",
                           partial_file_pos );
           }
         return 2;
@@ -610,7 +613,7 @@ int readblock( const int fd, char * buf, const int size ) 
throw()
   while( rest > 0 )
     {
     errno = 0;
-    const int n = read( fd, buf + size - rest, rest );
+    const int n = compat_wrap( read( fd, buf + size - rest, rest ));
     if( n > 0 ) rest -= n;
     else if( n == 0 ) break;
     else if( errno != EINTR && errno != EAGAIN ) break;
@@ -629,7 +632,7 @@ int writeblock( const int fd, const char * buf, const int 
size ) throw()
   while( rest > 0 )
     {
     errno = 0;
-    const int n = write( fd, buf + size - rest, rest );
+    const int n = compat_wrap( write( fd, buf + size - rest, rest ));
     if( n > 0 ) rest -= n;
     else if( errno && errno != EINTR && errno != EAGAIN ) break;
     }
_______________________________________________
Lzip-bug mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lzip-bug

Reply via email to