>>>>> "Georg" == Georg Baum <[EMAIL PROTECTED]> writes:

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

Georg> I did not test, but the logic complies with my beliefs.

Here is the 1.4.0cvs version, that I intend to apply unless you spot
something nasty.

JMarc

Index: src/insets/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.1003
diff -u -p -r1.1003 ChangeLog
--- src/insets/ChangeLog	16 Apr 2004 16:01:47 -0000	1.1003
+++ src/insets/ChangeLog	19 Apr 2004 15:23:19 -0000
@@ -1,3 +1,10 @@
+2004-04-19  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* insetbibtex.C (normalize_name): new helper function. Changes the
+	name to be suitable to use in a latex file (relative to master
+	buffer if necessary).
+	(latex): use normalize_name.
+
 2004-04-16  Angus Leeming  <[EMAIL PROTECTED]>
 
 	* render_graphic.h (checksum_, hasFileChanged): unused, so removed.
Index: src/insets/insetbibtex.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibtex.C,v
retrieving revision 1.47
diff -u -p -r1.47 insetbibtex.C
--- src/insets/insetbibtex.C	3 Apr 2004 08:37:10 -0000	1.47
+++ src/insets/insetbibtex.C	19 Apr 2004 15:23:19 -0000
@@ -29,6 +29,7 @@
 
 #include <fstream>
 
+using lyx::support::AbsolutePath;
 using lyx::support::ascii_lowercase;
 using lyx::support::ChangeExtension;
 using lyx::support::contains;
@@ -36,6 +37,7 @@ using lyx::support::findtexfile;
 using lyx::support::IsFileReadable;
 using lyx::support::ltrim;
 using lyx::support::MakeAbsPath;
+using lyx::support::MakeRelPath;
 using lyx::support::Path;
 using lyx::support::prefixIs;
 using lyx::support::rtrim;
@@ -91,6 +93,23 @@ string const InsetBibtex::getScreenLabel
 }
 
 
+namespace {
+
+string normalize_name(Buffer const & buffer, OutputParams const & runparams,
+		      string const & name, string const & ext)
+{
+	string const fname = MakeAbsPath(name, buffer.filePath());
+	if (AbsolutePath(name) || !IsFileReadable(fname + ext))
+		return name;
+	else if (!runparams.nice) 
+		return fname;
+	else 
+		return MakeRelPath(fname, buffer.getMasterBuffer()->filePath());
+}
+	
+}
+
+
 int InsetBibtex::latex(Buffer const & buffer, ostream & os,
 		       OutputParams const & runparams) const
 {
@@ -113,11 +132,8 @@ int InsetBibtex::latex(Buffer const & bu
 	// have a comma-separated list of bibliographies
 	string db_out;
 	while (!adb.empty()) {
-		if (!runparams.nice &&
-		    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, runparams,
+							   adb, ".bib"));
 		db_out += ',';
 		db_in = split(db_in, adb,',');
 	}
@@ -136,13 +152,11 @@ int InsetBibtex::latex(Buffer const & bu
 	// line count
 	int i = 0;
 
-	if (!runparams.nice
-	    && IsFileReadable(MakeAbsPath(style, buffer.filePath()) + ".bst")) {
-		style = MakeAbsPath(style, buffer.filePath());
-	}
-
 	if (!style.empty()) {
-		os << "\\bibliographystyle{" << style << "}\n";
+		os << "\\bibliographystyle{"
+		   << os::external_path(normalize_name(buffer, runparams, 
+						       style, ".bst"))
+		   << "}\n";
 		i += 1;
 	}
 

Reply via email to