mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
zlib changes. More strongly type gzFile variables. HAVE_ZLIB prob no longer works
This commit is contained in:
parent
70d4e01bde
commit
b63308f163
@ -18,20 +18,16 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
#include <zlib.h>
|
||||
#endif
|
||||
|
||||
namespace util {
|
||||
|
||||
ParseNumberException::ParseNumberException(StringPiece value) throw() {
|
||||
*this << "Could not parse \"" << value << "\" into a number";
|
||||
}
|
||||
|
||||
GZException::GZException(void *file) {
|
||||
GZException::GZException(gzFile file) {
|
||||
#ifdef HAVE_ZLIB
|
||||
int num;
|
||||
*this << gzerror( (gzFile) file, &num) << " from zlib";
|
||||
*this << gzerror( file, &num) << " from zlib";
|
||||
#endif // HAVE_ZLIB
|
||||
}
|
||||
|
||||
@ -56,7 +52,7 @@ FilePiece::~FilePiece() {
|
||||
// zlib took ownership
|
||||
file_.release();
|
||||
int ret;
|
||||
if (Z_OK != (ret = gzclose( (gzFile) gz_file_))) {
|
||||
if (Z_OK != (ret = gzclose(gz_file_))) {
|
||||
std::cerr << "could not close file " << file_name_ << " using zlib" << std::endl;
|
||||
abort();
|
||||
}
|
||||
@ -295,7 +291,7 @@ void FilePiece::ReadShift() {
|
||||
|
||||
ssize_t read_return;
|
||||
#ifdef HAVE_ZLIB
|
||||
read_return = gzread( (gzFile) gz_file_, static_cast<char*>(data_.get()) + already_read, default_map_size_ - already_read);
|
||||
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) {
|
||||
// Just get the position, don't actually seek. Apparently this is how you do it. . .
|
||||
|
@ -13,6 +13,10 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
#include <zlib.h>
|
||||
#endif
|
||||
|
||||
namespace util {
|
||||
|
||||
class ParseNumberException : public Exception {
|
||||
@ -23,7 +27,7 @@ class ParseNumberException : public Exception {
|
||||
|
||||
class GZException : public Exception {
|
||||
public:
|
||||
explicit GZException(void *file);
|
||||
explicit GZException(gzFile file);
|
||||
GZException() throw() {}
|
||||
~GZException() throw() {}
|
||||
};
|
||||
@ -117,7 +121,7 @@ class FilePiece {
|
||||
std::string file_name_;
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
void *gz_file_;
|
||||
gzFile gz_file_;
|
||||
#endif // HAVE_ZLIB
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user