#include "LaTeX.h"
#include "lyxlex.h"
#include "support/FileInfo.h"
-#include "error.h"
+#include "debug.h"
#include "support/lyxlib.h"
#include "support/syscall.h"
#include "support/syscontr.h"
-#include "pathstack.h"
+#include "support/path.h"
#include "bufferlist.h"
#include "minibuffer.h"
#include "gettext.h"
errstr += tmp;
tmp = frontStrip(readLine(lex.getFile()));
}
- lyxerr.debug("tmp: " + errstr);
+ lyxerr.debug() << "tmp: " << errstr << endl;
int line = 0;
// unfortunately the error line is not always given
// by "l.###" in the beginning of the error string
// msg.
if (contains(errstr, "l.")) {
// We make a const copy to make [] fast. (Asger)
- string const es = errstr;
+ string const es(errstr);
for (string::size_type i = 2; i < es.length(); ++i) {
if (es[i-2] == 'l' && es[i-1] == '.' &&
(es[i] >= '0' && es[i]<= '9')) {
void TeXErrors::printErrors()
{
- lyxerr.print("Printing errors.");
+ lyxerr << "Printing errors." << endl;
if (errors) {
Error *tmperr = errors;
do {
- lyxerr.print(string("Error in line ")
- + tostr(tmperr->error_in_line)
- + ": " + tmperr->error_desc
- + '\n' + tmperr->error_text);
- //%d: %s\n%s\n", tmperr->error_in_line,
- // tmperr->error_desc.c_str(),
- // tmperr->error_text.c_str());
+ lyxerr << "Error in line "
+ << tmperr->error_in_line
+ << ": " << tmperr->error_desc
+ << '\n' << tmperr->error_text << endl;
tmperr = tmperr->next_error;
} while (tmperr);
}
void TeXErrors::printStatus()
{
- lyxerr.print("Error struct:");
- lyxerr.print(string(" status: ") + tostr(status));
- lyxerr.print(string(" no err: ") + tostr(number_of_errors));
- if (status == LaTeX::NO_ERRORS) lyxerr.print("NO_ERRORS");
- if (status & LaTeX::NO_LOGFILE) lyxerr.print("NO_LOGFILE");
- if (status & LaTeX::NO_OUTPUT) lyxerr.print("NO_OUTPUT");
- if (status & LaTeX::UNDEF_REF) lyxerr. print("UNDEF_REF");
- if (status & LaTeX::RERUN) lyxerr. print("RERUN");
- if (status & LaTeX::TEX_ERROR) lyxerr.print("TEX_ERROR");
- if (status & LaTeX::TEX_WARNING) lyxerr.print("TEX_WARNING");
- if (status & LaTeX::NO_FILE) lyxerr.print("NO_FILE");
+ lyxerr << "Error struct:"
+ << "\n status: " << status
+ << "\n no err: " << number_of_errors << endl;
+ if (status == LaTeX::NO_ERRORS) lyxerr << "NO_ERRORS" << endl;
+ if (status & LaTeX::NO_LOGFILE) lyxerr << "NO_LOGFILE" << endl;
+ if (status & LaTeX::NO_OUTPUT) lyxerr << "NO_OUTPUT" << endl;
+ if (status & LaTeX::UNDEF_REF) lyxerr << "UNDEF_REF" << endl;
+ if (status & LaTeX::RERUN) lyxerr << "RERUN" << endl;
+ if (status & LaTeX::TEX_ERROR) lyxerr << "TEX_ERROR" << endl;
+ if (status & LaTeX::TEX_WARNING) lyxerr << "TEX_WARNING" << endl;
+ if (status & LaTeX::NO_FILE) lyxerr << "NO_FILE" << endl;
}
// Update the checksums
head.update();
- lyxerr.debug("Dependency file exists", Error::LATEX);
+ lyxerr[Debug::LATEX] << "Dependency file exists" << endl;
if (head.sumchange()) {
- lyxerr.debug("Dependency file has changed",
- Error::LATEX);
- lyxerr.debug(string(_("Run #")) + tostr(++count),
- Error::LATEX);
+ ++count;
+ lyxerr[Debug::LATEX]
+ << "Dependency file has changed\n"
+ << "Run #" << count << endl;
minib->Set(string(_("LaTeX run number ")) + tostr(count));
minib->Store();
this->operator()();
scanres = scanLogFile(terr);
if (scanres & LaTeX::ERRORS) return scanres; // return on error
} else {
- lyxerr.debug("return no_change", Error::LATEX);
+ lyxerr[Debug::LATEX] << "return no_change" << endl;
return LaTeX::NO_CHANGE;
}
} else {
- lyxerr.debug("Dependency file does not exist",
- Error::LATEX);
- lyxerr.debug(string(_("Run #")) + tostr(++count),
- Error::LATEX);
+ ++count;
+ lyxerr[Debug::LATEX] << "Dependency file does not exist\n"
+ << "Run #" << count << endl;
head.insert(file, true);
minib->Set(string(_("LaTeX run number ")) + tostr(count));
minib->Store();
//
if (rerun || head.sumchange()) {
rerun = false;
- lyxerr.debug("Dep. file has changed or rerun requested",
- Error::LATEX);
- lyxerr.debug(string("Run #") + tostr(++count),
- Error::LATEX);
+ ++count;
+ lyxerr[Debug::LATEX]
+ << "Dep. file has changed or rerun requested\n"
+ << "Run #" << count << endl;
minib->Set(string(_("LaTeX run number ")) + tostr(count));
minib->Store();
this->operator()();
deplog(head); // reads the latex log
head.update();
} else {
- lyxerr.debug("Dep. file has NOT changed", Error::LATEX);
+ lyxerr[Debug::LATEX] << "Dep. file has NOT changed" << endl;
}
// 1.5
// Yes rerun until message goes away, or until
// MAX_RUNS are reached.
rerun = false;
- lyxerr.debug(string(_("Run #")) + tostr(++count), Error::LATEX);
+ ++count;
+ lyxerr[Debug::LATEX] << "Run #" << count << endl;
minib->Set(string(_("LaTeX run number ")) + tostr(count));
minib->Store();
this->operator()();
// Write the dependencies to file.
head.write(depfile);
- lyxerr.debug("Done.", Error::LATEX);
+ lyxerr[Debug::LATEX] << "Done." << endl;
return scanres;
}
string tmp = cmd + ' ' + file + " > nul";
#endif
Systemcalls one;
- return one.Startscript(Systemcalls::System, tmp);
+ return one.startscript(Systemcalls::System, tmp);
}
bool LaTeX::runMakeIndex(string const &file)
{
- lyxerr.debug("idx file has been made,"
- " running makeindex on file "
- + file, Error::LATEX);
+ lyxerr[Debug::LATEX] << "idx file has been made,"
+ " running makeindex on file "
+ << file << endl;
// It should be possible to set the switches for makeindex
// sorting style and such. It would also be very convenient
string tmp = "makeindex -c -q ";
tmp += file;
Systemcalls one;
- one.Startscript(Systemcalls::System, tmp);
+ one.startscript(Systemcalls::System, tmp);
return true;
}
string tmp="bibtex ";
tmp += ChangeExtension(file, string(), true);
Systemcalls one;
- one.Startscript(Systemcalls::System, tmp);
+ one.startscript(Systemcalls::System, tmp);
return true;
}
int LaTeX::scanLogFile(TeXErrors &terr)
{
- string token;
int retval = NO_ERRORS;
-
- LyXLex lex(0, 0);
-
string tmp = ChangeExtension(file, ".log", true);
+ LyXLex lex(0, 0);
if (!lex.setFile(tmp)) {
// unable to open file
// return at once
retval |= NO_LOGFILE;
return retval;
}
-
+
+ string token;
while (lex.IsOK()) {
if (lex.EatLine())
token = lex.GetString();
else // blank line in the file being read
continue;
- lyxerr.debug(token, Error::LATEX);
+ lyxerr[Debug::LATEX] << token << endl;
if (prefixIs(token, "LaTeX Warning:")) {
// Here shall we handle different
// types of warnings
retval |= LATEX_WARNING;
- lyxerr.debug("LaTeX Warning.", Error::LATEX);
+ lyxerr[Debug::LATEX] << "LaTeX Warning." << endl;
if (contains(token, "Rerun to get cross-references")) {
retval |= RERUN;
- lyxerr.debug("We should rerun.", Error::LATEX);
+ lyxerr[Debug::LATEX]
+ << "We should rerun." << endl;
} else if (contains(token, "Citation")
&& contains(token, "on page")
&& contains(token, "undefined")) {
// Here shall we handle different
// types of errors
retval |= LATEX_ERROR;
- lyxerr.debug("LaTeX Error.", Error::LATEX);
+ lyxerr[Debug::LATEX] << "LaTeX Error." << endl;
// this is not correct yet
terr.scanError(lex);
num_errors++;
if (contains(desc, "Undefined control sequence")) {
retval |= TEX_ERROR;
- lyxerr.debug("TeX Error.", Error::LATEX);
+ lyxerr[Debug::LATEX] << "TeX Error." << endl;
terr.scanError(lex);
num_errors++;
} else {
if (prefixIs(tmp, "l.")) {
// we have a latex error
retval |= TEX_ERROR;
- lyxerr.debug("TeX Error.", Error::LATEX);
+ lyxerr[Debug::LATEX]
+ <<"TeX Error." << endl;
// get the line number:
int line = 0;
sscanf(tmp.c_str(), "l.%d", &line);
}
if (foundfile.empty()) continue;
- lyxerr.debug("Found file: "
- + foundfile,
- Error::LATEX);
+ lyxerr[Debug::LATEX] << "Found file: "
+ << foundfile << endl;
// Ok now we found a file.
// Now we should make sure that
// this is a file that we can
// absolute path and should
// be inserted.
if (AbsolutePath(foundfile)) {
- lyxerr.debug("AbsolutePath file: "
- + foundfile,
- Error::LATEX);
+ lyxerr[Debug::LATEX] << "AbsolutePath file: "
+ << foundfile << endl;
// On inital insert we want to do the update at once
// since this file can not be a file generated by
// the latex run.
// insert it into head
if (FileInfo(OnlyFilename(foundfile)).exist()) {
if (suffixIs(foundfile, ".aux")) {
- lyxerr.debug("We don't want "
- + OnlyFilename(foundfile)
- + " in the dep file",
- Error::LATEX);
+ lyxerr[Debug::LATEX] << "We don't want "
+ << OnlyFilename(foundfile)
+ << " in the dep file"
+ << endl;
} else if (suffixIs(foundfile, ".tex")) {
// This is a tex file generated by LyX
// and latex is not likely to change this
// during its runs.
- lyxerr.debug("Tmpdir TeX file: "
- + OnlyFilename(foundfile),
- Error::LATEX);
+ lyxerr[Debug::LATEX] << "Tmpdir TeX file: "
+ << OnlyFilename(foundfile)
+ << endl;
head.insert(foundfile, true);
} else {
- lyxerr.debug("In tmpdir file:"
- + OnlyFilename(foundfile),
- Error::LATEX);
+ lyxerr[Debug::LATEX] << "In tmpdir file:"
+ << OnlyFilename(foundfile)
+ << endl;
head.insert(OnlyFilename(foundfile));
}
continue;
// found in the same dir
// as the .lyx file and
// should be inserted.
- PathPush(path);
+ Path p(path);
if (FileInfo(foundfile).exist()) {
- lyxerr.print("LyX Strange: this should actually never"
- " happen anymore, this it should be"
- " handled by the Absolute check.");
- lyxerr.debug("Same Directory file: "
- + foundfile,
- Error::LATEX);
+ lyxerr << "LyX Strange: this should actually never"
+ " happen anymore, this it should be"
+ " handled by the Absolute check."
+ << endl;
+ lyxerr[Debug::LATEX] << "Same Directory file: "
+ << foundfile << endl;
head.insert(foundfile);
- PathPop();
continue;
}
- PathPop();
- lyxerr.debug("Not a file or we are unable to find it.",
- Error::LATEX);
-
-
+ lyxerr[Debug::LATEX]
+ << "Not a file or we are unable to find it."
+ << endl;
}
}
tmp = ChangeExtension(file,
all_files[i].extension,
true);
- lyxerr.debug("deptex: " + tmp, Error::LATEX);
+ lyxerr[Debug::LATEX] << "deptex: " << tmp << endl;
if (fi.newFile(tmp).exist())
head.insert(tmp);
}