X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLaTeX.C;h=b1758d2749634a7e49bd69b3d7dbd7da588a73d2;hb=a858be7332e331e0244e4dba7b0931b6072ffd3d;hp=6b4bc7bd1d931fe1a7814d46d0f2b194c0f90a96;hpb=0eccdd1c3613e5170deb77b22174dd0afde833e9;p=lyx.git diff --git a/src/LaTeX.C b/src/LaTeX.C index 6b4bc7bd1d..b1758d2749 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -24,11 +24,11 @@ #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" @@ -124,7 +124,7 @@ void TeXErrors::scanError(LyXLex &lex) 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 @@ -132,7 +132,7 @@ void TeXErrors::scanError(LyXLex &lex) // 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')) { @@ -190,17 +190,14 @@ void TeXErrors::insertError(int line, string const &error_desc, 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); } @@ -214,17 +211,17 @@ void TeXErrors::printWarnings() 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; } @@ -283,26 +280,25 @@ int LaTeX::run(TeXErrors &terr, MiniBuffer *minib) // 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(); @@ -356,10 +352,10 @@ int LaTeX::run(TeXErrors &terr, MiniBuffer *minib) // 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()(); @@ -369,7 +365,7 @@ int LaTeX::run(TeXErrors &terr, MiniBuffer *minib) 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 @@ -403,7 +399,8 @@ int LaTeX::run(TeXErrors &terr, MiniBuffer *minib) // 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()(); @@ -415,7 +412,7 @@ int LaTeX::run(TeXErrors &terr, MiniBuffer *minib) // Write the dependencies to file. head.write(depfile); - lyxerr.debug("Done.", Error::LATEX); + lyxerr[Debug::LATEX] << "Done." << endl; return scanres; } @@ -428,15 +425,15 @@ int LaTeX::operator()() 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 @@ -445,7 +442,7 @@ bool LaTeX::runMakeIndex(string const &file) string tmp = "makeindex -c -q "; tmp += file; Systemcalls one; - one.Startscript(Systemcalls::System, tmp); + one.startscript(Systemcalls::System, tmp); return true; } @@ -471,7 +468,7 @@ bool LaTeX::runBibTeX(string const &file) string tmp="bibtex "; tmp += ChangeExtension(file, string(), true); Systemcalls one; - one.Startscript(Systemcalls::System, tmp); + one.startscript(Systemcalls::System, tmp); return true; } @@ -483,36 +480,35 @@ bool LaTeX::runBibTeX(string const &file) 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")) { @@ -536,7 +532,7 @@ int LaTeX::scanLogFile(TeXErrors &terr) // 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++; @@ -550,7 +546,7 @@ int LaTeX::scanLogFile(TeXErrors &terr) 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 { @@ -560,7 +556,8 @@ int LaTeX::scanLogFile(TeXErrors &terr) 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); @@ -636,9 +633,8 @@ void LaTeX::deplog(DepTable & head) } 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 @@ -648,9 +644,8 @@ void LaTeX::deplog(DepTable & head) // 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. @@ -662,22 +657,22 @@ void LaTeX::deplog(DepTable & head) // 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; @@ -687,24 +682,21 @@ void LaTeX::deplog(DepTable & head) // 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; } } @@ -719,7 +711,7 @@ void LaTeX::deptex(DepTable &head) 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); }