[iostreams] 64-bit patch for gzip

Currently the gzip test fails on 64-bit system because of 32/64-bit issues in 'iostreams/filter/gzip.hpp'. Attached patch fixes this, and additionally renames the functions read_byte() to read_uint8() and read_long() to read_uint32() as this is what they actually do. The patch has been tested on a 32 bit system (Linux/GCC 3.4.2) and on a 64 bit system (Tru64/CXX 6.5-042, GCC 3.4.3). Ok to commit? Markus Index: filter/gzip.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/iostreams/filter/gzip.hpp,v retrieving revision 1.14 diff -u -w -r1.14 gzip.hpp --- filter/gzip.hpp 20 May 2005 04:11:11 -0000 1.14 +++ filter/gzip.hpp 8 Jun 2005 09:12:39 -0000 @@ -353,21 +353,21 @@ static gzip_params make_params(int window_bits); template<typename Source> - static int read_byte(Source& src, int error) + static uint8_t read_uint8(Source& src, int error) { int c; if ((c = boost::iostreams::get(src)) == EOF || c == WOULD_BLOCK) throw gzip_error(error); - return static_cast<unsigned char>(traits_type::to_char_type(c)); + return static_cast<uint8_t>(traits_type::to_char_type(c)); } template<typename Source> - static long read_long(Source& src, int error) + static uint32_t read_uint32(Source& src, int error) { - int b1 = read_byte(src, error); - int b2 = read_byte(src, error); - int b3 = read_byte(src, error); - int b4 = read_byte(src, error); + uint8_t b1 = read_uint8(src, error); + uint8_t b2 = read_uint8(src, error); + uint8_t b3 = read_uint8(src, error); + uint8_t b4 = read_uint8(src, error); return b1 + (b2 << 8) + (b3 << 16) + (b4 << 24); } @@ -412,16 +412,17 @@ { throw gzip_error(gzip::bad_header); } - mtime_ = read_long(src, gzip::bad_header); // MTIME. - read_byte(src, gzip::bad_header); // XFL. - os_ = read_byte(src, gzip::bad_header); // OS. + mtime_ = read_uint32(src, gzip::bad_header); // MTIME. + read_uint8(src, gzip::bad_header); // XFL. + os_ = read_uint8(src, gzip::bad_header); // OS. if (flags & boost::iostreams::gzip::flags::text) flags_ |= f_text; // Skip extra field. (From J. Halleaux; see note at top.) if (flags & gzip::flags::extra) { - int length = read_byte(src, gzip::bad_header) + - (read_byte(src, gzip::bad_header) << 8); + int length = static_cast<int>( + read_uint8(src, gzip::bad_header) + + (read_uint8(src, gzip::bad_header) << 8)); // length is garbage if EOF but the loop below will quit anyway. do { } while (length-- != 0 && !is_eof(boost::iostreams::get(src))); @@ -432,8 +433,8 @@ if (flags & gzip::flags::comment) // Read comment. comment_ = read_string(src); if (flags & gzip::flags::header_crc) { // Skip header crc. - read_byte(src, gzip::bad_header); - read_byte(src, gzip::bad_header); + read_uint8(src, gzip::bad_header); + read_uint8(src, gzip::bad_header); } } @@ -447,13 +448,11 @@ footer += c; detail::range_adapter<input, std::string> rng(footer.begin(), footer.end()); - if ( static_cast<unsigned long>(read_long(rng, gzip::bad_footer)) - != - this->crc() ) + if ( read_uint32(rng, gzip::bad_footer) != this->crc() ) { throw gzip_error(gzip::bad_crc); } - if (read_long(rng, gzip::bad_footer) != this->total_out()) + if (static_cast<int>(read_uint32(rng, gzip::bad_footer)) != this->total_out()) throw gzip_error(gzip::bad_length); } enum {

Markus Schöpflin wrote:
Currently the gzip test fails on 64-bit system because of 32/64-bit issues in 'iostreams/filter/gzip.hpp'. Attached patch fixes this, and additionally renames the functions read_byte() to read_uint8() and read_long() to read_uint32() as this is what they actually do.
Thanks!
The patch has been tested on a 32 bit system (Linux/GCC 3.4.2) and on a 64 bit system (Tru64/CXX 6.5-042, GCC 3.4.3). Ok to commit?
Let me test it first on more platforms, then I'll commit it.
Markus
Jonathan

Jonathan Turkanis wrote:
Markus Schöpflin wrote:
The patch has been tested on a 32 bit system (Linux/GCC 3.4.2) and on a 64 bit system (Tru64/CXX 6.5-042, GCC 3.4.3). Ok to commit?
Let me test it first on more platforms, then I'll commit it.
Ok, you're the boss. :-) Markus

Jonathan Turkanis wrote:
Markus Schöpflin wrote:
The patch has been tested on a 32 bit system (Linux/GCC 3.4.2) and on a 64 bit system (Tru64/CXX 6.5-042, GCC 3.4.3). Ok to commit?
Let me test it first on more platforms, then I'll commit it.
Done. Thanks again!
Jonathan

Markus Schöpflin wrote:
Currently the gzip test fails on 64-bit system because of 32/64-bit issues in 'iostreams/filter/gzip.hpp'. Attached patch fixes this, and additionally renames the functions read_byte() to read_uint8() and read_long() to read_uint32() as this is what they actually do.
The patch has been tested on a 32 bit system (Linux/GCC 3.4.2) and on a 64 bit system (Tru64/CXX 6.5-042, GCC 3.4.3). Ok to commit?
I see the gzip tests are still failing. Could you check to see whether I appliced your patch correctly? (I changed the formatting in a few places, and may have accidentally broken it.) Jonathan

Jonathan Turkanis wrote:
Markus Schöpflin wrote:
I see the gzip tests are still failing. Could you check to see whether I appliced your patch correctly? (I changed the formatting in a few places, and may have accidentally broken it.)
I don't think you have broken anything, you just need to be more patient. :-) The machine is still plowing it's way through the next regression round. The currently visible results are from Tue, 7 Jun 2005 10:27:49 UTC, and you check-in was at "2005/06/08 16:27:58", so no need to worry yet. Markus

Markus Schöpflin wrote:
Jonathan Turkanis wrote:
Markus Schöpflin wrote:
I see the gzip tests are still failing. Could you check to see whether I appliced your patch correctly? (I changed the formatting in a few places, and may have accidentally broken it.)
I don't think you have broken anything, you just need to be more patient. :-)
Okay, sorry ;-) Jonathan
participants (3)
-
Jonathan Turkanis
-
Markus Schöpflin
-
Markus Schöpflin