Jean-Marc Lasgouttes wrote:
Georg, I would appreciate if you could check the logic of this patch,

Turns out a last minute change broke the logic. Try the following (slightly simpler) version instead.


JMarc
Index: src/insets/insetbib.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/Attic/insetbib.C,v
retrieving revision 1.97
diff -u -r1.97 insetbib.C
--- src/insets/insetbib.C       27 Nov 2002 10:30:25 -0000      1.97
+++ src/insets/insetbib.C       18 Apr 2004 19:24:28 -0000
@@ -146,6 +146,22 @@
        return _("BibTeX Generated References");
 }
 
+namespace {
+
+string normalize_name(Buffer const * buffer, string const & name,
+                     string const & ext)
+{
+       string const fname = MakeAbsPath(name, buffer->filePath());
+       if (AbsolutePath(name) || !IsFileReadable(fname + ext))
+               return name;
+       else if (!buffer->niceFile) 
+               return fname;
+       else 
+               return MakeRelPath(fname, buffer->getMasterBuffer()->filePath());
+}
+       
+}
+
 
 int InsetBibtex::latex(Buffer const * buffer, ostream & os,
                       bool /*fragile*/, bool/*fs*/) const
@@ -154,9 +170,6 @@
        // 1. \bibliographystyle{style}
        // 2. \addcontentsline{...} - if option bibtotoc set
        // 3. \bibliography{database}
-       string adb;
-       string db_in = getContents();
-       db_in = split(db_in, adb, ',');
 
        // Style-Options
        string style = getOptions(); // maybe empty! and with bibtotoc
@@ -168,13 +181,10 @@
                }
        }
 
-       if (!buffer->niceFile
-           && IsFileReadable(MakeAbsPath(style, buffer->filePath()) + ".bst")) {
-               style = MakeAbsPath(style, buffer->filePath());
-       }
-
        if (!style.empty()) { // we want no \biblio...{}
-               os << "\\bibliographystyle{" << style << "}\n";
+               os << "\\bibliographystyle{"
+                  << os::external_path(normalize_name(buffer, style, ".bst"))
+                  << "}\n";
        }
 
        // bibtotoc-Option
@@ -206,15 +216,16 @@
        // If we generate in a temp dir, we might need to give an
        // absolute path there. This is a bit complicated since we can
        // have a comma-separated list of bibliographies
-       string db_out;
+       string adb, db_out;
+       string db_in = getContents();
+       db_in = split(db_in, adb, ',');
        while (!adb.empty()) {
-               if (!buffer->niceFile &&
-                   IsFileReadable(MakeAbsPath(adb, buffer->filePath())+".bib"))
-                        adb = os::external_path(MakeAbsPath(adb, buffer->filePath()));
-               db_out += adb;
+               db_out += os::external_path(normalize_name(buffer,
+                                                          adb, ".bib"));
                db_out += ',';
                db_in= split(db_in, adb,',');
        }
+
        db_out = rtrim(db_out, ",");
        os   << "\\bibliography{" << db_out << "}\n";
        return 2;

Reply via email to