]> git.lyx.org Git - features.git/commitdiff
Fix bug #6170 (Latex Compiler error when lyx file is located in a path which contains...
authorEnrico Forestieri <forenr@lyx.org>
Mon, 29 Aug 2011 17:02:27 +0000 (17:02 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Mon, 29 Aug 2011 17:02:27 +0000 (17:02 +0000)
This removes \input@path handling.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39563 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/Buffer.h
src/BufferList.cpp
src/graphics/PreviewLoader.cpp
src/insets/InsetInclude.cpp

index 1ebe6cffb2a7aaf761e813ba44875b2799f4d9a0..fdcbb04259525cf4922e50cf425506398a3ff3d2 100644 (file)
@@ -1300,7 +1300,6 @@ bool Buffer::write(ostream & ofs) const
 
 
 bool Buffer::makeLaTeXFile(FileName const & fname,
-                          string const & original_path,
                           OutputParams const & runparams_in,
                           bool output_preamble, bool output_body) const
 {
@@ -1341,8 +1340,7 @@ bool Buffer::makeLaTeXFile(FileName const & fname,
 
        try {
                os.texrow().reset();
-               writeLaTeXSource(os, original_path,
-                     runparams, output_preamble, output_body);
+               writeLaTeXSource(os, runparams, output_preamble, output_body);
        }
        catch (EncodingException & e) {
                odocstringstream ods;
@@ -1385,7 +1383,6 @@ bool Buffer::makeLaTeXFile(FileName const & fname,
 
 
 void Buffer::writeLaTeXSource(otexstream & os,
-                          string const & original_path,
                           OutputParams const & runparams_in,
                           bool const output_preamble, bool const output_body) const
 {
@@ -1412,57 +1409,12 @@ void Buffer::writeLaTeXSource(otexstream & os,
        }
        LYXERR(Debug::INFO, "lyx document header finished");
 
-       // There are a few differences between nice LaTeX and usual files:
-       // usual is \batchmode and has a
-       // special input@path to allow the including of figures
-       // with either \input or \includegraphics (what figinsets do).
-       // input@path is set when the actual parameter
-       // original_path is set. This is done for usual tex-file, but not
-       // for nice-latex-file. (Matthias 250696)
-       // Note that input@path is only needed for something the user does
-       // in the preamble, included .tex files or ERT, files included by
-       // LyX work without it.
+       // With respect to nice LaTeX, usual files have \batchmode
        if (output_preamble) {
                if (!runparams.nice) {
                        // code for usual, NOT nice-latex-file
                        os << "\\batchmode\n"; // changed from \nonstopmode
                }
-               if (!original_path.empty()) {
-                       // FIXME UNICODE
-                       // We don't know the encoding of inputpath
-                       docstring const inputpath = from_utf8(support::latex_path(original_path));
-                       docstring uncodable_glyphs;
-                       Encoding const * const enc = runparams.encoding;
-                       if (enc) {
-                               for (size_t n = 0; n < inputpath.size(); ++n) {
-                                       docstring const glyph =
-                                               docstring(1, inputpath[n]);
-                                       if (enc->latexChar(inputpath[n], true) != glyph) {
-                                               LYXERR0("Uncodable character '"
-                                                       << glyph
-                                                       << "' in input path!");
-                                               uncodable_glyphs += glyph;
-                                       }
-                               }
-                       }
-
-                       // warn user if we found uncodable glyphs.
-                       if (!uncodable_glyphs.empty()) {
-                               frontend::Alert::warning(_("Uncodable character in file path"),
-                                               support::bformat(_("The path of your document\n"
-                                                 "(%1$s)\n"
-                                                 "contains glyphs that are unknown in the\n"
-                                                 "current document encoding (namely %2$s).\n"
-                                                 "This will likely result in incomplete output.\n\n"
-                                                 "Choose an appropriate document encoding (such as utf8)\n"
-                                                 "or change the file path name."), inputpath, uncodable_glyphs));
-                       } else {
-                               os << "\\makeatletter\n"
-                                  << "\\def\\input@path{{"
-                                  << inputpath << "/}}\n"
-                                  << "\\makeatother\n";
-                       }
-               }
 
                // get parent macros (if this buffer has a parent) which will be
                // written at the document begin further down.
@@ -1710,7 +1662,6 @@ int Buffer::runChktex()
        // get LaTeX-Filename
        FileName const path(temppath());
        string const name = addName(path.absFileName(), latexName());
-       string const org_path = filePath();
 
        PathChanger p(path); // path to LaTeX file
        message(_("Running chktex..."));
@@ -1720,7 +1671,7 @@ int Buffer::runChktex()
        runparams.flavor = OutputParams::LATEX;
        runparams.nice = false;
        runparams.linelen = lyxrc.plaintext_linelen;
-       makeLaTeXFile(FileName(name), org_path, runparams);
+       makeLaTeXFile(FileName(name), runparams);
 
        TeXErrors terr;
        Chktex chktex(lyxrc.chktex_command, onlyFileName(name), filePath());
@@ -3143,7 +3094,7 @@ void Buffer::getSourceCode(odocstream & os, string const format,
                else {
                        // latex or literate
                        otexstream ots(os, d->texrow);
-                       writeLaTeXSource(ots, string(), runparams, true, true);
+                       writeLaTeXSource(ots, runparams, true, true);
                }
        } else {
                runparams.par_begin = par_begin;
@@ -3526,7 +3477,7 @@ bool Buffer::doExport(string const & format, bool put_in_tempdir,
        // LaTeX backend
        else if (backend_format == format) {
                runparams.nice = true;
-               if (!makeLaTeXFile(FileName(filename), string(), runparams)) {
+               if (!makeLaTeXFile(FileName(filename), runparams)) {
                        if (d->cloned_buffer_) {
                                d->cloned_buffer_->d->errorLists["Export"] =
                                        d->errorLists["Export"];
@@ -3540,7 +3491,7 @@ bool Buffer::doExport(string const & format, bool put_in_tempdir,
                return false;
        } else {
                runparams.nice = false;
-               if (!makeLaTeXFile(FileName(filename), filePath(), runparams)) {
+               if (!makeLaTeXFile(FileName(filename), runparams)) {
                        if (d->cloned_buffer_) {
                                d->cloned_buffer_->d->errorLists["Export"] =
                                        d->errorLists["Export"];
index 273123a5e6fc001770005a4b438ea473e1ce5f6f..6a224261bc42bc60fd51c057ac0f9c2e164c5787 100644 (file)
@@ -276,7 +276,6 @@ public:
 
        /// Just a wrapper for writeLaTeXSource, first creating the ofstream.
        bool makeLaTeXFile(support::FileName const & filename,
-                          std::string const & original_path,
                           OutputParams const &,
                           bool output_preamble = true,
                           bool output_body = true) const;
@@ -303,7 +302,6 @@ public:
            \endcode
         */
        void writeLaTeXSource(otexstream & os,
-                          std::string const & original_path,
                           OutputParams const &,
                           bool output_preamble = true,
                           bool output_body = true) const;
index e19c8aa63d3f86523e7da5f4609fef018c28cb82..01b344f039d85920aee497935fd01a4ddd245326 100644 (file)
@@ -212,8 +212,7 @@ void BufferList::updateIncludedTeXfiles(string const & masterTmpDir,
        for (; it != end; ++it) {
                if (!(*it)->isDepClean(masterTmpDir)) {
                        string writefile = addName(masterTmpDir, (*it)->latexName());
-                       (*it)->makeLaTeXFile(FileName(writefile), masterTmpDir,
-                                            runparams, false);
+                       (*it)->makeLaTeXFile(FileName(writefile), runparams, false);
                        (*it)->markDepClean(masterTmpDir);
                }
        }
index c7c55d2aabfbdadc37cccb73e154b6be513bb536..d2b15eb9516052d79ecc3752465efdac9d7b9344 100644 (file)
@@ -710,7 +710,7 @@ void PreviewLoader::Impl::dumpPreamble(otexstream & os) const
        runparams.nice = true;
        runparams.moving_arg = true;
        runparams.free_spacing = true;
-       buffer_.writeLaTeXSource(os, buffer_.filePath(), runparams, true, false);
+       buffer_.writeLaTeXSource(os, runparams, true, false);
 
        // FIXME! This is a HACK! The proper fix is to control the 'true'
        // passed to WriteStream below:
index 971e11f2a0e461a347f094b16b6ba64ce5234106..324b4a07628f9ae9f6fff7c503fdebe9ce06daa2 100644 (file)
@@ -605,10 +605,6 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
                        formats.extension(inc_format)));
 
                // FIXME: handle non existing files
-               // FIXME: Second argument is irrelevant!
-               // since only_body is true, makeLaTeXFile will not look at second
-               // argument. Should we set it to string(), or should makeLaTeXFile
-               // make use of it somehow? (JMarc 20031002)
                // The included file might be written in a different encoding
                // and language.
                Encoding const * const oldEnc = runparams.encoding;
@@ -621,8 +617,7 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
                runparams.master_language = buffer().params().language;
                runparams.par_begin = 0;
                runparams.par_end = tmp->paragraphs().size();
-               if (!tmp->makeLaTeXFile(tmpwritefile, masterFileName(buffer()).
-                               onlyPath().absFileName(), runparams, false)) {
+               if (!tmp->makeLaTeXFile(tmpwritefile, runparams, false)) {
                        docstring msg = bformat(_("Included file `%1$s' "
                                        "was not exported correctly.\nWarning: "
                                        "LaTeX export is probably incomplete."),
@@ -661,7 +656,8 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
                // In this case, it's not a LyX file, so we copy the file
                // to the temp dir, so that .aux files etc. are not created
                // in the original dir. Files included by this file will be
-               // found via input@path, see ../Buffer.cpp.
+               // found via the environment variable TEXINPUTS, which may be
+               // set in preferences and by default includes the original dir.
                unsigned long const checksum_in  = included_file.checksum();
                unsigned long const checksum_out = writefile.checksum();