diff options
author | Tom Tromey <tromey@gcc.gnu.org> | 2004-10-11 18:45:43 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2004-10-11 18:45:43 +0000 |
commit | 17210dff5d26c1e820e0cd678a46cf2795c41e4c (patch) | |
tree | 01e6e6bb5683a568f3e4d7be40728b9b503640c4 /zlib/contrib/iostream | |
parent | 1325e2b519f4a1b3d9fbd92ece22bdf3e4df0b06 (diff) | |
download | gcc-17210dff5d26c1e820e0cd678a46cf2795c41e4c.zip gcc-17210dff5d26c1e820e0cd678a46cf2795c41e4c.tar.gz gcc-17210dff5d26c1e820e0cd678a46cf2795c41e4c.tar.bz2 |
re PR libgcj/14856 (Update bundled zlib)
PR libgcj/14856:
* Imported zlib 1.2.1; merged local changes.
From-SVN: r88898
Diffstat (limited to 'zlib/contrib/iostream')
-rw-r--r-- | zlib/contrib/iostream/zfstream.cpp | 36 | ||||
-rw-r--r-- | zlib/contrib/iostream/zfstream.h | 34 |
2 files changed, 28 insertions, 42 deletions
diff --git a/zlib/contrib/iostream/zfstream.cpp b/zlib/contrib/iostream/zfstream.cpp index a690bbe..d0cd85f 100644 --- a/zlib/contrib/iostream/zfstream.cpp +++ b/zlib/contrib/iostream/zfstream.cpp @@ -1,5 +1,4 @@ -#include <memory.h> #include "zfstream.h" gzfilebuf::gzfilebuf() : @@ -17,15 +16,13 @@ gzfilebuf::~gzfilebuf() { } gzfilebuf *gzfilebuf::open( const char *name, - int io_mode ) { + int io_mode ) { if ( is_open() ) return NULL; char char_mode[10]; - char *p; - memset(char_mode,'\0',10); - p = char_mode; + char *p = char_mode; if ( io_mode & ios::in ) { mode = ios::in; @@ -48,6 +45,9 @@ gzfilebuf *gzfilebuf::open( const char *name, *p++ = '9'; } + // Put the end-of-string indicator + *p = '\0'; + if ( (file = gzopen(name, char_mode)) == NULL ) return NULL; @@ -58,15 +58,13 @@ gzfilebuf *gzfilebuf::open( const char *name, } gzfilebuf *gzfilebuf::attach( int file_descriptor, - int io_mode ) { + int io_mode ) { if ( is_open() ) return NULL; char char_mode[10]; - char *p; - memset(char_mode,'\0',10); - p = char_mode; + char *p = char_mode; if ( io_mode & ios::in ) { mode = ios::in; @@ -89,6 +87,9 @@ gzfilebuf *gzfilebuf::attach( int file_descriptor, *p++ = '9'; } + // Put the end-of-string indicator + *p = '\0'; + if ( (file = gzdopen(file_descriptor, char_mode)) == NULL ) return NULL; @@ -112,13 +113,13 @@ gzfilebuf *gzfilebuf::close() { } -int gzfilebuf::setcompressionlevel( short comp_level ) { +int gzfilebuf::setcompressionlevel( int comp_level ) { return gzsetparams(file, comp_level, -2); } -int gzfilebuf::setcompressionstrategy( short comp_strategy ) { +int gzfilebuf::setcompressionstrategy( int comp_strategy ) { return gzsetparams(file, -2, comp_strategy); @@ -151,7 +152,7 @@ int gzfilebuf::underflow() { if ( out_waiting() ) { if ( flushbuf() == EOF ) - return EOF; + return EOF; } } @@ -180,11 +181,11 @@ int gzfilebuf::overflow( int c ) { setg(0,0,0); } else { if (in_avail()) { - return EOF; + return EOF; } if (out_waiting()) { if (flushbuf() == EOF) - return EOF; + return EOF; } } @@ -282,12 +283,11 @@ void gzfilestream_common::close() { } -gzfilebuf *gzfilestream_common::rdbuf() { - +gzfilebuf *gzfilestream_common::rdbuf() +{ return &buffer; - } - + gzifstream::gzifstream() : ios( gzfilestream_common::rdbuf() ) { diff --git a/zlib/contrib/iostream/zfstream.h b/zlib/contrib/iostream/zfstream.h index c87fa08..ed79098 100644 --- a/zlib/contrib/iostream/zfstream.h +++ b/zlib/contrib/iostream/zfstream.h @@ -1,6 +1,6 @@ -#ifndef _zfstream_h -#define _zfstream_h +#ifndef zfstream_h +#define zfstream_h #include <fstream.h> #include "zlib.h" @@ -16,8 +16,8 @@ public: gzfilebuf *attach( int file_descriptor, int io_mode ); gzfilebuf *close(); - int setcompressionlevel( short comp_level ); - int setcompressionstrategy( short comp_strategy ); + int setcompressionlevel( int comp_level ); + int setcompressionstrategy( int comp_strategy ); inline int is_open() const { return (file !=NULL); } @@ -98,18 +98,19 @@ private: T val; }; -template<class T> gzofstream &operator<<(gzofstream &s, - const gzomanip<T> &m) { +template<class T> gzofstream &operator<<(gzofstream &s, const gzomanip<T> &m) +{ return (*m.func)(s, m.val); - } -inline gzofstream &setcompressionlevel( gzofstream &s, int l ) { +inline gzofstream &setcompressionlevel( gzofstream &s, int l ) +{ (s.rdbuf())->setcompressionlevel(l); return s; } -inline gzofstream &setcompressionstrategy( gzofstream &s, int l ) { +inline gzofstream &setcompressionstrategy( gzofstream &s, int l ) +{ (s.rdbuf())->setcompressionstrategy(l); return s; } @@ -125,18 +126,3 @@ inline gzomanip<int> setcompressionstrategy(int l) } #endif - - - - - - - - - - - - - - - |