]> git.lyx.org Git - lyx.git/blobdiff - src/Lexer.cpp
adjust
[lyx.git] / src / Lexer.cpp
index 38465f92ed2aa7ebb33708a0a82b2bbfc2059335..ce8de705470bde04ad3f5d76e8710ea8dac34b10 100644 (file)
 
 #include "support/convert.h"
 #include "support/filetools.h"
+#include "support/gzstream.h"
 #include "support/lstrings.h"
 #include "support/lyxalgo.h"
 #include "support/types.h"
 #include "support/unicode.h"
 
-#include <boost/iostreams/filtering_streambuf.hpp>
-#include <boost/iostreams/filter/gzip.hpp>
-#include <boost/iostreams/device/file.hpp>
-#include <boost/utility.hpp>
-
-namespace io = boost::iostreams;
+#include <boost/noncopyable.hpp>
 
 #include <functional>
 #include <istream>
@@ -110,7 +106,7 @@ public:
        std::filebuf fb_;
 
        /// gz_ is only used to open files, the stream is accessed through is.
-       io::filtering_istreambuf gz_;
+       gz::gzstreambuf gz_;
 
        /// the stream that we use.
        std::istream is;
@@ -261,28 +257,27 @@ bool Lexer::Pimpl::setFile(FileName const & filename)
 
        if (format == "gzip" || format == "zip" || format == "compress") {
                LYXERR(Debug::LYXLEX) << "lyxlex: compressed" << endl;
-
                // The check only outputs a debug message, because it triggers
                // a bug in compaq cxx 6.2, where is_open() returns 'true' for
                // a fresh new filebuf.  (JMarc)
-               if (!gz_.empty() || istream::off_type(is.tellg()) > -1)
-                       LYXERR(Debug::LYXLEX) << "Error in Lexer::setFile: "
+               if (gz_.is_open() || istream::off_type(is.tellg()) > -1)
+                       lyxerr[Debug::LYXLEX] << "Error in LyXLex::setFile: "
                                "file or stream already set." << endl;
-               gz_.push(io::gzip_decompressor());
-               gz_.push(io::file_source(filename.toFilesystemEncoding()));
+               gz_.open(filename.toFilesystemEncoding().c_str(), ios::in);
                is.rdbuf(&gz_);
                name = filename.absFilename();
                lineno = 0;
-               return gz_.component<io::file_source>(1)->is_open() && is.good();
+               return gz_.is_open() && is.good();
        } else {
                LYXERR(Debug::LYXLEX) << "lyxlex: UNcompressed" << endl;
 
                // The check only outputs a debug message, because it triggers
                // a bug in compaq cxx 6.2, where is_open() returns 'true' for
                // a fresh new filebuf.  (JMarc)
-               if (fb_.is_open() || istream::off_type(is.tellg()) > 0)
+               if (fb_.is_open() || istream::off_type(is.tellg()) > 0) {
                        LYXERR(Debug::LYXLEX) << "Error in Lexer::setFile: "
                                "file or stream already set." << endl;
+               }
                fb_.open(filename.toFilesystemEncoding().c_str(), ios::in);
                is.rdbuf(&fb_);
                name = filename.absFilename();
@@ -294,9 +289,10 @@ bool Lexer::Pimpl::setFile(FileName const & filename)
 
 void Lexer::Pimpl::setStream(istream & i)
 {
-       if (fb_.is_open() || istream::off_type(is.tellg()) > 0)
+       if (fb_.is_open() || istream::off_type(is.tellg()) > 0) {
                LYXERR(Debug::LYXLEX)  << "Error in Lexer::setStream: "
                        "file or stream already set." << endl;
+       }
        is.rdbuf(i.rdbuf());
        lineno = 0;
 }