]> git.lyx.org Git - features.git/commitdiff
Set correct path to (biblatex) bibliography databases that are entered relative to...
authorJuergen Spitzmueller <spitz@lyx.org>
Sat, 7 Apr 2018 20:09:06 +0000 (22:09 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 8 Apr 2018 11:25:17 +0000 (13:25 +0200)
Fixes: #11105
(cherry picked from commit 2ecc3b09c6a9c663bec87356b2ec512f37676c5c)

src/Buffer.cpp
src/support/filetools.cpp
src/support/filetools.h
status.23x

index a9f66a674cbf9d72d585433222572e8a160c7a08..fa5cad952207e9a5aa72efa4fb868cf1bf2758e1 100644 (file)
@@ -3185,9 +3185,27 @@ vector<docstring> const Buffer::prepareBibFilePaths(OutputParams const & runpara
                string utf8input = to_utf8(it->first);
                string database =
                        prepareFileNameForLaTeX(utf8input, ".bib", runparams.nice);
-               FileName const try_in_file =
+               FileName try_in_file =
                        makeAbsPath(database + ".bib", filePath());
-               bool const not_from_texmf = try_in_file.isReadableFile();
+               bool not_from_texmf = try_in_file.isReadableFile();
+               // If the file has not been found, try with the real file name
+               // (it might come from a child in a sub-directory)
+               if (!not_from_texmf) {
+                       try_in_file = it->second;
+                       if (try_in_file.isReadableFile()) {
+                               // Check if the file is in texmf
+                               FileName kpsefile(findtexfile(changeExtension(utf8input, "bib"), "bib", true));
+                               not_from_texmf = kpsefile.empty()
+                                               || kpsefile.absFileName() != try_in_file.absFileName();
+                               if (not_from_texmf)
+                                       // If this exists, make path relative to the master
+                                       // FIXME Unicode
+                                       database = removeExtension(
+                                                       prepareFileNameForLaTeX(to_utf8(makeRelPath(from_utf8(try_in_file.absFileName()),
+                                                                                                   from_utf8(filePath()))),
+                                                                               ".bib", runparams.nice));
+                       }
+               }
 
                if (!runparams.inComment && !runparams.dryrun && !runparams.nice &&
                    not_from_texmf) {
index 12457cb3ae328a4c2c679887b4313d1949356286..3d2346c7cd01b1bf3ae40efb43218fe340eb3775 100644 (file)
@@ -1094,7 +1094,8 @@ cmd_ret const runCommand(string const & cmd)
 }
 
 
-FileName const findtexfile(string const & fil, string const & /*format*/)
+FileName const findtexfile(string const & fil, string const & /*format*/,
+                                                  bool const onlykpse)
 {
        /* There is no problem to extend this function too use other
           methods to look for files. It could be setup to look
@@ -1107,9 +1108,11 @@ FileName const findtexfile(string const & fil, string const & /*format*/)
 
        // If the file can be found directly, we just return a
        // absolute path version of it.
-       FileName const absfile(makeAbsPath(fil));
-       if (absfile.exists())
-               return absfile;
+       if (!onlykpse) {
+               FileName const absfile(makeAbsPath(fil));
+               if (absfile.exists())
+                       return absfile;
+       }
 
        // Now we try to find it using kpsewhich.
        // It seems from the kpsewhich manual page that it is safe to use
index 0146474d0715d903e69c00fbffac1eb09bf8cae1..96a884273b520368885584554e26717c05c7a87c 100644 (file)
@@ -282,7 +282,8 @@ bool readLink(FileName const & file, FileName & link);
  * \param format The file format as used by kpsewhich, e.g. "bib", "bst" etc.
  */
 FileName const findtexfile(std::string const & fil,
-                             std::string const & format);
+                                                  std::string const & format,
+                                                  bool const onlykpse = false);
 
 /** \param file1, file2 the two files to be compared. Must have absolute paths.
  *  \returns 1 if \c file1 has a more recent timestamp than \c file2,
index 869cdee493d95f31419c34eebcfebfe92ddbd96b..f1c93081d5e9ebc348747385fcc2aa984ee9ff01 100644 (file)
@@ -94,7 +94,7 @@ What's new
 
 * DOCUMENT INPUT/OUTPUT
 
-- Fix language settings annd line spacing in InPreamble-titles
+- Fix language settings and line spacing in InPreamble-titles
   (bug 9332, 1049).
 
 - Respect 'literal' setting when calculating longest bibitem (bug 10817).
@@ -104,6 +104,9 @@ What's new
 
 - Fix polyglossia language switches for Arabic (bug 11057).
 
+- Set correct path to (biblatex) bibliography databases that are entered
+  relative to child documents (bug 11105).
+
 
 * LYX2LYX