From 4b527153ccf2a2830e38038ce4cf06ccc764d310 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 31 May 2008 09:03:28 +0000 Subject: fix zlib type issues on 32-bit systems --- src/core/commandbuffer.cc | 9 ++++++--- src/core/netclient.cc | 5 +++-- src/core/netconnection.cc | 4 ++-- src/core/netconnection.h | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc index 6c4dbca..0d02e6b 100644 --- a/src/core/commandbuffer.cc +++ b/src/core/commandbuffer.cc @@ -207,8 +207,11 @@ void CommandBuffer::exec() void CommandBuffer::complete(std::string &input, size_t &pos) { std::list match; - - std::string partial = input.substr(0, pos); + size_t start = 0; + if (input.c_str()[0] == '/' || input.c_str()[0] == '\\') + start = 1; + + std::string partial = input.substr(start, pos); if (!partial.size()) return; aux::to_lowercase(partial); @@ -255,7 +258,7 @@ void CommandBuffer::complete(std::string &input, size_t &pos) if (maxmatch.size() > partial.size()) { if (match.size()==1) maxmatch += ' '; - input.replace(0, pos, maxmatch); + input.replace(start, pos, maxmatch); pos = maxmatch.size(); } diff --git a/src/core/netclient.cc b/src/core/netclient.cc index dc4a0bd..5254b23 100644 --- a/src/core/netclient.cc +++ b/src/core/netclient.cc @@ -132,7 +132,8 @@ void NetClient::transmit(int serverfd) char zbuf[BLOCKSIZE]; const char *data = 0; - size_t compressed_size = BLOCKSIZE - 5; + unsigned long compressed_size = BLOCKSIZE - 5; + unsigned long uncompressed_size = sendq.size(); size_t total_size = 0; memset(zbuf,0, sizeof(zbuf)); @@ -140,7 +141,7 @@ void NetClient::transmit(int serverfd) Stats::network_uncompressed_bytes_sent += sendq.size(); // zlib compress - int status = compress((Bytef*)(zbuf+4), &compressed_size, (Bytef*)sendq.c_str(), sendq.size()); + int status = compress((Bytef*)(zbuf+4), &compressed_size, (Bytef*)sendq.c_str(), uncompressed_size); if ((status == Z_OK) && (compressed_size + 4 < sendq.size())) { // add a header to the compress packet diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc index 6606a9f..a0a0497 100644 --- a/src/core/netconnection.cc +++ b/src/core/netconnection.cc @@ -164,11 +164,11 @@ void NetConnection::receive() zrecvbuf[received_compressed_size] = *c; received_compressed_size++; - if (received_compressed_size == compressed_size) { + if (received_compressed_size == (size_t) compressed_size) { // uncompress char zunbuf[BLOCKSIZE]; memset(zunbuf, 0, sizeof(zunbuf)); - size_t zunbuf_size = BLOCKSIZE - 1; + unsigned long zunbuf_size = BLOCKSIZE - 1; int status = uncompress((Bytef *) zunbuf, &zunbuf_size, (Bytef *) zrecvbuf, compressed_size); diff --git a/src/core/netconnection.h b/src/core/netconnection.h index ddc70f0..d3c6cf7 100644 --- a/src/core/netconnection.h +++ b/src/core/netconnection.h @@ -107,7 +107,7 @@ private: bool receive_compressed; size_t received_compressed_size; - size_t compressed_size; + unsigned long compressed_size; char zrecvbuf[BLOCKSIZE]; }; -- cgit v1.2.3