X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLaTeX.C;h=8c8091fe4fc13e68c3f258821e07f82d49cc5472;hb=35204f8f33d7400a5fefeffea533fb4cb4097211;hp=17854a217adce14fd55370a6ac049d3fdc45cedf;hpb=ca5411f913b77fbcec30f2b35b8a0d0a65fa5649;p=lyx.git diff --git a/src/LaTeX.C b/src/LaTeX.C index 17854a217a..8c8091fe4f 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -21,8 +21,6 @@ #include "debug.h" #include "DepTable.h" -#include "frontends/Application.h" - #include "support/filetools.h" #include "support/convert.h" #include "support/lstrings.h" @@ -35,26 +33,27 @@ #include -using lyx::support::absolutePath; -using lyx::support::bformat; -using lyx::support::changeExtension; -using lyx::support::contains; -using lyx::support::findtexfile; -using lyx::support::getcwd; -using lyx::support::onlyFilename; -using lyx::support::prefixIs; -using lyx::support::quoteName; -using lyx::support::rtrim; -using lyx::support::split; -using lyx::support::subst; -using lyx::support::suffixIs; -using lyx::support::Systemcall; -using lyx::support::unlink; -using lyx::support::trim; - -using lyx::docstring; - -namespace os = lyx::support::os; + +namespace lyx { + +using support::absolutePath; +using support::bformat; +using support::changeExtension; +using support::contains; +using support::findtexfile; +using support::getcwd; +using support::onlyFilename; +using support::prefixIs; +using support::quoteName; +using support::rtrim; +using support::split; +using support::subst; +using support::suffixIs; +using support::Systemcall; +using support::unlink; +using support::trim; + +namespace os = support::os; namespace fs = boost::filesystem; using boost::regex; @@ -96,8 +95,8 @@ docstring runMessage(unsigned int count) * CLASS TEXERRORS */ -void TeXErrors::insertError(int line, string const & error_desc, - string const & error_text) +void TeXErrors::insertError(int line, docstring const & error_desc, + docstring const & error_text) { Error newerr(line, error_desc, error_text); errors.push_back(newerr); @@ -159,6 +158,10 @@ void LaTeX::deleteFilesOnError() const string const ind = changeExtension(ofname, ".ind"); unlink(ind); + // nomencl file + string const nls = changeExtension(ofname, ".nls"); + unlink(nls); + // Also remove the aux file string const aux = changeExtension(ofname, ".aux"); unlink(aux); @@ -180,7 +183,7 @@ int LaTeX::run(TeXErrors & terr) bool rerun = false; // rerun requested // The class LaTeX does not know the temp path. - theApp->bufferList().updateIncludedTeXfiles(getcwd(), runparams); + theBufferList().updateIncludedTeXfiles(getcwd(), runparams); // Never write the depfile if an error was encountered. @@ -284,6 +287,12 @@ int LaTeX::run(TeXErrors & terr) message(_("Running MakeIndex.")); rerun |= runMakeIndex(onlyFilename(changeExtension(file, ".idx")), runparams); } + if (head.haschanged(onlyFilename(changeExtension(file, ".nlo")))) { + lyxerr[Debug::LATEX] << "Running MakeIndex for nomencl." << endl; + message(_("Running MakeIndex for nomencl.")); + string const nomenclstr = " -s nomencl.ist -o " + changeExtension(file, ".nls"); + rerun |= runMakeIndex(onlyFilename(changeExtension(file, ".nlo")), runparams, nomenclstr); + } // run bibtex // if (scanres & UNDEF_CIT || scanres & RERUN || run_bibtex) @@ -353,6 +362,14 @@ int LaTeX::run(TeXErrors & terr) rerun = runMakeIndex(onlyFilename(changeExtension(file, ".idx")), runparams); } + // I am not pretty sure if need this twice. + if (head.haschanged(onlyFilename(changeExtension(file, ".nlo")))) { + lyxerr[Debug::LATEX] << "Running MakeIndex for nomencl." << endl; + message(_("Running MakeIndex for nomencl.")); + string nomenclstr = " -s nomencl.ist -o " + changeExtension(file, ".nls"); + rerun |= runMakeIndex(onlyFilename(changeExtension(file, ".nlo")), runparams, nomenclstr); + } + // 2 // we will only run latex more if the log file asks for it. // or if the sumchange() is true. @@ -397,14 +414,17 @@ int LaTeX::startscript() } -bool LaTeX::runMakeIndex(string const & f, OutputParams const & runparams) +bool LaTeX::runMakeIndex(string const & f, OutputParams const & runparams, + string const & params) { - lyxerr[Debug::LATEX] << "idx file has been made," - " running makeindex on file " - << f << endl; - string tmp = lyxrc.index_command + " "; + lyxerr[Debug::LATEX] + << "idx file has been made, running makeindex on file " + << f << endl; + string tmp = lyxrc.index_command + ' '; + tmp = subst(tmp, "$$lang", runparams.document_language); tmp += quoteName(f); + tmp += params; Systemcall one; one.startscript(Systemcall::Wait, tmp); return true; @@ -651,7 +671,11 @@ int LaTeX::scanLogFile(TeXErrors & terr) last_line = line; } if (line_count <= 5) { - terr.insertError(line, desc, errstr); + // FIXME UNICODE + // We have no idea what the encoding of the log file is + // (probably pure ascii, but maybe some localized + // latex compilers or packages exist) + terr.insertError(line, from_utf8(desc), from_utf8(errstr)); ++num_errors; } } @@ -763,6 +787,7 @@ void LaTeX::deplog(DepTable & head) // but instead only a line like this into the log: // Writing index file sample.idx static regex reg5("Writing index file ([^ ]+).*"); + static regex regnomencl("Writing nomenclature file ([^ ]+).*"); // If a toc should be created, MikTex does not write a line like // \openout# = `sample.toc'. // but only a line like this into the log: @@ -811,6 +836,8 @@ void LaTeX::deplog(DepTable & head) handleFoundFile(sub.str(1), head); else if (regex_match(token, sub, reg5)) handleFoundFile(sub.str(1), head); + else if (regex_match(token, sub, regnomencl)) + handleFoundFile(sub.str(1), head); else if (regex_match(token, sub, miktexTocReg)) handleFoundFile(changeExtension(file, ".toc"), head); } @@ -818,3 +845,6 @@ void LaTeX::deplog(DepTable & head) // Make sure that the main .tex file is in the dependancy file. head.insert(onlyFilename(file), true); } + + +} // namespace lyx