#include <config.h>
#include "Lexer.h"
+#include "Format.h"
#include "support/convert.h"
#include "support/debug.h"
bool Lexer::Pimpl::setFile(FileName const & filename)
{
// Check the format of the file.
- string const format = filename.guessFormatFromContents();
-
- if (format == "gzip" || format == "zip" || format == "compress") {
+ if (formats.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
"file or stream already set.");
gz_.open(filename.toFilesystemEncoding().c_str(), ios::in);
is.rdbuf(&gz_);
- name = filename.absFilename();
+ name = filename.absFileName();
lineno = 0;
if (!gz_.is_open() || !is.good())
return false;
}
fb_.open(filename.toSafeFilesystemEncoding().c_str(), ios::in);
is.rdbuf(&fb_);
- name = filename.absFilename();
+ name = filename.absFileName();
lineno = 0;
if (!fb_.is_open() || !is.good())
return false;
// Skip byte order mark.
if (is.peek() == 0xef) {
- int c = is.get();
+ is.get();
if (is.peek() == 0xbb) {
- c = is.get();
+ is.get();
LASSERT(is.get() == 0xbf, /**/);
} else
is.unget();
is.get(cc);
c = cc;
//LYXERR(Debug::LYXLEX, "Lexer::EatLine read char: `" << c << '\'');
- if (c != '\r')
+ if (c != '\r' && is)
buff.push_back(c);
}