]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeX.C
Updates from Bennett and myself.
[lyx.git] / src / LaTeX.C
index 8cbb27f2fee7a88607af3c539bf742aa4043338f..0557b7ab7d041ce68656269132e8cdc439424aa1 100644 (file)
@@ -40,8 +40,10 @@ using support::absolutePath;
 using support::bformat;
 using support::changeExtension;
 using support::contains;
+using support::FileName;
 using support::findtexfile;
 using support::getcwd;
+using support::makeAbsPath;
 using support::onlyFilename;
 using support::prefixIs;
 using support::quoteName;
@@ -95,8 +97,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);
@@ -127,11 +129,11 @@ LaTeX::LaTeX(string const & latex, OutputParams const & rp,
        : cmd(latex), file(f), path(p), runparams(rp)
 {
        num_errors = 0;
-       depfile = file + ".dep";
        if (prefixIs(cmd, "pdf")) { // Do we use pdflatex ?
-               depfile += "-pdf";
+               depfile = FileName(makeAbsPath(file + ".dep-pdf"));
                output_file = changeExtension(file,".pdf");
        } else {
+               depfile = FileName(makeAbsPath(file + ".dep"));
                output_file = changeExtension(file,".dvi");
        }
 }
@@ -148,22 +150,20 @@ void LaTeX::deleteFilesOnError() const
 
        // but the reason for the error might be in a generated file...
 
-       string const ofname = onlyFilename(file);
-
        // bibtex file
-       string const bbl = changeExtension(ofname, ".bbl");
+       FileName const bbl(makeAbsPath(changeExtension(file, ".bbl")));
        unlink(bbl);
 
        // makeindex file
-       string const ind = changeExtension(ofname, ".ind");
+       FileName const ind(makeAbsPath(changeExtension(file, ".ind")));
        unlink(ind);
 
        // nomencl file
-       string const nls = changeExtension(ofname, ".nls");
+       FileName const nls(makeAbsPath(changeExtension(file, ".nls")));
        unlink(nls);
 
        // Also remove the aux file
-       string const aux = changeExtension(ofname, ".aux");
+       FileName const aux(makeAbsPath(changeExtension(file, ".aux")));
        unlink(aux);
 }
 
@@ -203,7 +203,7 @@ int LaTeX::run(TeXErrors & terr)
        //             remake the dependency file.
        //
 
-       bool had_depfile = fs::exists(depfile);
+       bool had_depfile = fs::exists(depfile.toFilesystemEncoding());
        bool run_bibtex = false;
        string aux_file = onlyFilename(changeExtension(file, "aux"));
 
@@ -281,15 +281,15 @@ int LaTeX::run(TeXErrors & terr)
                && fs::is_empty(changeExtension(file, ".idx"));
 
        // run makeindex
-       if (head.haschanged(onlyFilename(changeExtension(file, ".idx")))) {
+       if (head.haschanged(FileName(makeAbsPath(onlyFilename(changeExtension(file, ".idx")))))) {
                // no checks for now
                lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
                message(_("Running MakeIndex."));
                rerun |= runMakeIndex(onlyFilename(changeExtension(file, ".idx")), runparams);
        }
-       if (head.haschanged(onlyFilename(changeExtension(file, ".nlo")))) {
+       if (head.haschanged(FileName(makeAbsPath(onlyFilename(changeExtension(file, ".nlo")))))) {
                lyxerr[Debug::LATEX] << "Running MakeIndex for nomencl." << endl;
-               message(_("Running Makeindex for nomencl."));
+               message(_("Running MakeIndex for nomencl."));
                string const nomenclstr = " -s nomencl.ist -o " + changeExtension(file, ".nls");
                rerun |= runMakeIndex(onlyFilename(changeExtension(file, ".nlo")), runparams, nomenclstr);
        }
@@ -355,7 +355,7 @@ int LaTeX::run(TeXErrors & terr)
        // more after this.
 
        // run makeindex if the <file>.idx has changed or was generated.
-       if (head.haschanged(onlyFilename(changeExtension(file, ".idx")))) {
+       if (head.haschanged(FileName(makeAbsPath(onlyFilename(changeExtension(file, ".idx")))))) {
                // no checks for now
                lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
                message(_("Running MakeIndex."));
@@ -363,9 +363,9 @@ int LaTeX::run(TeXErrors & terr)
        }
 
        // I am not pretty sure if need this twice. 
-       if (head.haschanged(onlyFilename(changeExtension(file, ".nlo")))) {
+       if (head.haschanged(FileName(makeAbsPath(onlyFilename(changeExtension(file, ".nlo")))))) {
                lyxerr[Debug::LATEX] << "Running MakeIndex for nomencl." << endl;
-               message(_("Running Makeindex for nomencl. "));
+               message(_("Running MakeIndex for nomencl."));
                string nomenclstr = " -s nomencl.ist -o " + changeExtension(file, ".nls");
                rerun |= runMakeIndex(onlyFilename(changeExtension(file, ".nlo")), runparams, nomenclstr);
        }
@@ -525,14 +525,14 @@ void LaTeX::updateBibtexDependencies(DepTable & dep,
                     it2 != it->databases.end(); ++it2) {
                        string file = findtexfile(*it2, "bib");
                        if (!file.empty())
-                               dep.insert(file, true);
+                               dep.insert(FileName(makeAbsPath(file)), true);
                }
 
                for (set<string>::const_iterator it2 = it->styles.begin();
                     it2 != it->styles.end(); ++it2) {
                        string file = findtexfile(*it2, "bst");
                        if (!file.empty())
-                               dep.insert(file, true);
+                               dep.insert(FileName(makeAbsPath(file)), true);
                }
        }
 }
@@ -671,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;
                                }
                        }
@@ -721,10 +725,10 @@ void handleFoundFile(string const & ff, DepTable & head)
                lyxerr[Debug::DEPEND] << "AbsolutePath file: "
                                      << foundfile << endl;
                // On initial insert we want to do the update at once
-               // since this file can not be a file generated by
+               // since this file cannot be a file generated by
                // the latex run.
                if (fs::exists(foundfile) && !fs::is_directory(foundfile))
-                       head.insert(foundfile, true);
+                       head.insert(FileName(makeAbsPath(foundfile)), true);
 
                return;
        }
@@ -749,13 +753,13 @@ void handleFoundFile(string const & ff, DepTable & head)
                                << "Tmpdir TeX file: "
                                << onlyfile
                                << endl;
-                       head.insert(onlyfile, true);
+                       head.insert(FileName(makeAbsPath(onlyfile)), true);
                } else {
                        lyxerr[Debug::DEPEND]
                                << "In tmpdir file:"
                                << onlyfile
                                << endl;
-                       head.insert(onlyfile);
+                       head.insert(FileName(makeAbsPath(onlyfile)));
                }
        } else
                lyxerr[Debug::DEPEND]
@@ -839,7 +843,7 @@ void LaTeX::deplog(DepTable & head)
        }
 
        // Make sure that the main .tex file is in the dependancy file.
-       head.insert(onlyFilename(file), true);
+       head.insert(FileName(makeAbsPath(onlyFilename(file))), true);
 }