]> git.lyx.org Git - lyx.git/blobdiff - src/support/gzstream.cpp
Maintain plain layout for separating paragraphs when switching layouts (#11936)
[lyx.git] / src / support / gzstream.cpp
index fe521f3087066708e8d63a647bba143d973ea004..232e86bb3d5487ab7284d50c3593d7774489476c 100644 (file)
@@ -35,6 +35,8 @@
 # include <string.h> // for memcpy
 #endif
 
+using namespace std;
+
 #ifdef GZSTREAM_NAMESPACE
 namespace GZSTREAM_NAMESPACE {
 #endif
@@ -49,23 +51,23 @@ namespace GZSTREAM_NAMESPACE {
 
 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;
 }
@@ -77,14 +79,14 @@ gzstreambuf * gzstreambuf::close() {
         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();
@@ -116,10 +118,10 @@ int gzstreambuf::flush_buffer() {
 }
 
 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)
@@ -129,7 +131,7 @@ int gzstreambuf::overflow( int c) { // used for output buffer only
 
 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)
@@ -153,13 +155,13 @@ gzstreambase::~gzstreambase() {
 
 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