#include <config.h>
-#include "gzstream.h"
+#include "support/gzstream.h"
+
#include <iostream>
#ifdef HAVE_STRING_H
# include <string.h> // for memcpy
#endif
+using namespace std;
+
#ifdef GZSTREAM_NAMESPACE
namespace GZSTREAM_NAMESPACE {
#endif
gzstreambuf* gzstreambuf::open( const char* name, int open_mode) {
if ( is_open())
- return (gzstreambuf*)0;
+ return (gzstreambuf*)(nullptr);
mode = open_mode;
// no append nor read/write mode
- if ((mode & std::ios::ate) || (mode & std::ios::app)
- || ((mode & std::ios::in) && (mode & std::ios::out)))
- return (gzstreambuf*)0;
+ if ((mode & ios::ate) || (mode & ios::app)
+ || ((mode & ios::in) && (mode & ios::out)))
+ return (gzstreambuf*)(nullptr);
char fmode[10];
char* fmodeptr = fmode;
- if ( mode & std::ios::in)
+ if ( mode & ios::in)
*fmodeptr++ = 'r';
- else if ( mode & std::ios::out)
+ else if ( mode & ios::out)
*fmodeptr++ = 'w';
*fmodeptr++ = 'b';
*fmodeptr = '\0';
file = gzopen( name, fmode);
- if (file == 0)
- return (gzstreambuf*)0;
+ if (file == nullptr)
+ return (gzstreambuf*)(nullptr);
opened = 1;
return this;
}
if ( gzclose( file) == Z_OK)
return this;
}
- return (gzstreambuf*)0;
+ return (gzstreambuf*)(nullptr);
}
int gzstreambuf::underflow() { // used for input buffer only
if ( gptr() && ( gptr() < egptr()))
return * reinterpret_cast<unsigned char *>( gptr());
- if ( ! (mode & std::ios::in) || ! opened)
+ if ( ! (mode & ios::in) || ! opened)
return EOF;
// Josuttis' implementation of inbuf
int n_putback = gptr() - eback();
}
int gzstreambuf::overflow( int c) { // used for output buffer only
- if ( ! ( mode & std::ios::out) || ! opened)
+ if ( ! ( mode & ios::out) || ! opened)
return EOF;
if (c != EOF) {
- *pptr() = c;
+ *pptr() = (char) c;
pbump(1);
}
if ( flush_buffer() == EOF)
int gzstreambuf::sync() {
// Changed to use flush_buffer() instead of overflow( EOF)
- // which caused improper behavior with std::endl and flush(),
+ // which caused improper behavior with endl and flush(),
// bug reported by Vincent Ricard.
if ( pptr() && pptr() > pbase()) {
if ( flush_buffer() == EOF)
void gzstreambase::open( const char* name, int open_mode) {
if ( ! buf.open( name, open_mode))
- clear( rdstate() | std::ios::badbit);
+ clear( rdstate() | ios::badbit);
}
void gzstreambase::close() {
if ( buf.is_open())
if ( ! buf.close())
- clear( rdstate() | std::ios::badbit);
+ clear( rdstate() | ios::badbit);
}
#ifdef GZSTREAM_NAMESPACE