X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLexer.cpp;h=c6402aec6f39f69e966b6afe17710d44aebeb5e8;hb=3bf1b97ae547aea5d0243e41b2d8af463a6e40c5;hp=08fb469ce392392ec3bce8a9ebea7ca866c88d24;hpb=d38eddb397de982a379d8c0644c6ca2190c67fe9;p=features.git diff --git a/src/Lexer.cpp b/src/Lexer.cpp index 08fb469ce3..c6402aec6f 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -14,7 +14,6 @@ #include #include "Lexer.h" -#include "Format.h" #include "support/convert.h" #include "support/debug.h" @@ -25,6 +24,7 @@ #include "support/lstrings.h" #include "support/lyxalgo.h" +#include // sort, lower_bound #include #include #include @@ -80,9 +80,6 @@ public: bool inputAvailable(); /// void pushToken(string const &); - /// fb_ is only used to open files, the stream is accessed through is. - filebuf fb_; - /// gz_ is only used to open files, the stream is accessed through is. gz::gzstreambuf gz_; @@ -148,7 +145,7 @@ bool compareTags(LexerKeyword const & a, LexerKeyword const & b) Lexer::Pimpl::Pimpl(LexerKeyword * tab, int num) - : is(&fb_), table(tab), no_items(num), + : is(&gz_), table(tab), no_items(num), status(0), lineno(0), commentChar('#') { verifyTable(); @@ -234,38 +231,14 @@ void Lexer::Pimpl::popTable() bool Lexer::Pimpl::setFile(FileName const & filename) { - // Check the format of the file. - if (theFormats().isZippedFile(filename)) { - LYXERR(Debug::LYXLEX, "lyxlex: compressed"); - // 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_.is_open() || istream::off_type(is.tellg()) > -1) - LYXERR(Debug::LYXLEX, "Error in LyXLex::setFile: " - "file or stream already set."); + LYXERR0("Error in LyXLex::setFile: file or stream already set."); gz_.open(filename.toFilesystemEncoding().c_str(), ios::in); is.rdbuf(&gz_); name = filename.absFileName(); lineno = 0; if (!gz_.is_open() || !is.good()) return false; - } else { - LYXERR(Debug::LYXLEX, "lyxlex: UNcompressed"); - - // 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) { - LYXERR(Debug::LYXLEX, "Error in Lexer::setFile: " - "file or stream already set."); - } - fb_.open(filename.toSafeFilesystemEncoding().c_str(), ios::in); - is.rdbuf(&fb_); - name = filename.absFileName(); - lineno = 0; - if (!fb_.is_open() || !is.good()) - return false; - } // Skip byte order mark. if (is.peek() == 0xef) { @@ -283,10 +256,8 @@ bool Lexer::Pimpl::setFile(FileName const & filename) void Lexer::Pimpl::setStream(istream & i) { - if (fb_.is_open() || istream::off_type(is.tellg()) > 0) { - LYXERR(Debug::LYXLEX, "Error in Lexer::setStream: " - "file or stream already set."); - } + if (gz_.is_open() || istream::off_type(is.tellg()) > 0) + LYXERR0("Error in Lexer::setStream: file or stream already set."); is.rdbuf(i.rdbuf()); lineno = 0; }