Skip to content

Commit

Permalink
HAVE_ZLIB
Browse files Browse the repository at this point in the history
git-svn-id: file:///dev/shm/somefilter.svn@449 e102df66-1e2e-11dd-9b44-c24451a4db5e
  • Loading branch information
kpu committed Oct 27, 2010
1 parent 20899dc commit 0232df3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions util/file_piece.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <sys/stat.h>
#include <unistd.h>

#ifdef USE_ZLIB
#ifdef HAVE_ZLIB
#include <zlib.h>
#endif

Expand All @@ -31,10 +31,10 @@ ParseNumberException::ParseNumberException(StringPiece value) throw() {
}

GZException::GZException(void *file) {
#ifdef USE_ZLIB
#ifdef HAVE_ZLIB
int num;
*this << gzerror(file, &num) << " from zlib";
#endif // USE_ZLIB
#endif // HAVE_ZLIB
}

int OpenReadOrThrow(const char *name) {
Expand Down Expand Up @@ -62,7 +62,7 @@ FilePiece::FilePiece(int fd, const char *name, std::ostream *show_progress, off_
}

FilePiece::~FilePiece() {
#ifdef USE_ZLIB
#ifdef HAVE_ZLIB
if (gz_file_) {
// zlib took ownership
file_.release();
Expand All @@ -76,7 +76,7 @@ FilePiece::~FilePiece() {
}

void FilePiece::Initialize(const char *name, std::ostream *show_progress, off_t min_buffer) throw (GZException) {
#ifdef USE_ZLIB
#ifdef HAVE_ZLIB
gz_file_ = NULL;
#endif
file_name_ = name;
Expand All @@ -99,7 +99,7 @@ void FilePiece::Initialize(const char *name, std::ostream *show_progress, off_t
Shift();
// gzip detect.
if ((position_end_ - position_) > 2 && *position_ == 0x1f && static_cast<unsigned char>(*(position_ + 1)) == 0x8b) {
#ifndef USE_ZLIB
#ifndef HAVE_ZLIB
UTIL_THROW(GZException, "Looks like a gzip file but support was not compiled in.");
#endif
if (!fallback_to_read_) {
Expand Down Expand Up @@ -232,7 +232,7 @@ void FilePiece::TransitionToRead() throw (GZException) {
position_ = data_.begin();
position_end_ = position_;

#ifdef USE_ZLIB
#ifdef HAVE_ZLIB
assert(!gz_file_);
gz_file_ = gzdopen(file_.get(), "r");
if (!gz_file_) {
Expand Down Expand Up @@ -274,7 +274,7 @@ void FilePiece::ReadShift() throw(GZException, EndOfFileException) {
}

ssize_t read_return;
#ifdef USE_ZLIB
#ifdef HAVE_ZLIB
read_return = gzread(gz_file_, static_cast<char*>(data_.get()) + already_read, default_map_size_ - already_read);
if (read_return == -1) throw GZException(gz_file_);
if (total_size_ != kBadSize) {
Expand Down
6 changes: 3 additions & 3 deletions util/file_piece.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <cstddef>

#define USE_ZLIB
#define HAVE_ZLIB

namespace util {

Expand Down Expand Up @@ -114,9 +114,9 @@ class FilePiece {

std::string file_name_;

#ifdef USE_ZLIB
#ifdef HAVE_ZLIB
void *gz_file_;
#endif // USE_ZLIB
#endif // HAVE_ZLIB
};

} // namespace util
Expand Down
2 changes: 1 addition & 1 deletion util/file_piece_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE(StreamReadLine) {
BOOST_CHECK_THROW(test.get(), EndOfFileException);
}

#ifdef USE_ZLIB
#ifdef HAVE_ZLIB

// gzip file
BOOST_AUTO_TEST_CASE(PlainZipReadLine) {
Expand Down

0 comments on commit 0232df3

Please sign in to comment.