Fix bug 2186 (from G. Baum)

* insetbibtex.C (latex): copy the .bst files to the temp
	dir before running LaTeX, as is done for .bib files, graphics etc.
	(bug 2186)

	* insetgraphics.C (RemoveExtension): remove. The inset will use
	the version from filetools instead.

	* filetools.C (RemoveExtension): new function.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_4_X@16972 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2007-01-31 15:01:03 +00:00
parent 8e39249c62
commit 48d4b9f85b
7 changed files with 62 additions and 12 deletions

View File

@ -1,3 +1,12 @@
2007-01-31 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* insetbibtex.C (latex): copy the .bst files to the temp
dir before running LaTeX, as is done for .bib files, graphics etc.
(bug 2186)
* insetgraphics.C (RemoveExtension): remove. The inset will use
the version from filetools instead.
2007-01-19 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* insetbranch.C (textString): implement, so that branches appear

View File

@ -50,6 +50,7 @@ using lyx::support::MakeAbsPath;
using lyx::support::MakeRelPath;
using lyx::support::Path;
using lyx::support::prefixIs;
using lyx::support::RemoveExtension;
using lyx::support::rtrim;
using lyx::support::split;
using lyx::support::subst;
@ -164,7 +165,8 @@ int InsetBibtex::latex(Buffer const & buffer, ostream & os,
if (!runparams.inComment && !runparams.nice &&
IsFileReadable(in_file)) {
database = FileName(database).mangledFilename();
// mangledFilename() needs the extension
database = RemoveExtension(FileName(in_file).mangledFilename());
string const out_file = MakeAbsPath(database + ".bib",
buffer.getMasterBuffer()->temppath());
@ -208,12 +210,42 @@ int InsetBibtex::latex(Buffer const & buffer, ostream & os,
int nlines = 0;
if (!style.empty()) {
string base =
normalize_name(buffer, runparams, style, ".bst");
string const in_file = base + ".bst";
// If this style does not come from texmf and we are not
// exporting to .tex copy it to the tmp directory.
// This prevents problems with spaces and 8bit charcaters
// in the file name.
if (!runparams.inComment && !runparams.nice &&
IsFileReadable(in_file)) {
// use new style name
base = RemoveExtension(
FileName(in_file).mangledFilename());
string const out_file = MakeAbsPath(base + ".bst",
buffer.getMasterBuffer()->temppath());
bool const success = copy(in_file, out_file);
if (!success) {
lyxerr << "Failed to copy '" << in_file
<< "' to '" << out_file << "'"
<< endl;
}
}
os << "\\bibliographystyle{"
<< latex_path(normalize_name(buffer, runparams, style, ".bst"))
<< latex_path(normalize_name(buffer, runparams, base, ".bst"))
<< "}\n";
nlines += 1;
}
// Post this warning only once.
static bool warned_about_bst_spaces = false;
if (!warned_about_bst_spaces && runparams.nice && contains(style, ' ')) {
warned_about_bst_spaces = true;
Alert::warning(_("Export Warning!"),
_("There are spaces in the path to your BibTeX style file.\n"
"BibTeX will be unable to find it."));
}
if (!db_out.empty() && buffer.params().use_bibtopic){
os << "\\begin{btSect}{" << db_out << "}\n";
string btprint = getSecOptions();

View File

@ -101,6 +101,7 @@ using lyx::support::GetExtension;
using lyx::support::IsFileReadable;
using lyx::support::latex_path;
using lyx::support::OnlyFilename;
using lyx::support::RemoveExtension;
using lyx::support::rtrim;
using lyx::support::subst;
using lyx::support::Systemcall;
@ -119,15 +120,6 @@ using std::ostringstream;
namespace {
// This function is a utility function
// ... that should be with ChangeExtension ...
inline
string const RemoveExtension(string const & filename)
{
return ChangeExtension(filename, string());
}
/// Find the most suitable image format for images in \p format
/// Note that \p format may be unknown (i. e. an empty string)
string findTargetFormat(string const & format, OutputParams const & runparams)

View File

@ -1,3 +1,7 @@
2007-01-31 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* filetools.C (RemoveExtension): new function.
2007-01-08 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* os_unix.C (canAutoOpenFile, autoOpenFile): on Mac OS X, use

View File

@ -788,6 +788,12 @@ string const ChangeExtension(string const & oldname, string const & extension)
}
string const RemoveExtension(string const & name)
{
return ChangeExtension(name, string());
}
/// Return the extension of the file (not including the .)
string const GetExtension(string const & name)
{

View File

@ -170,6 +170,9 @@ std::string const AddPath(std::string const & path, std::string const & path2);
std::string const
ChangeExtension(std::string const & oldname, std::string const & extension);
/// Remove the extension from \p name
std::string const RemoveExtension(std::string const & name);
/// Return the extension of the file (not including the .)
std::string const GetExtension(std::string const & name);

View File

@ -80,7 +80,11 @@ What's new
- Fix import of \fullcite commands from LaTeX.
- Update bibliography references when the entry has been changed (bug 2744).
- Update bibliography references when the entry has been changed (bug
2744).
- The BibTeX style files (bst files) can now live in paths with spaces
(bug 2186).
- Fixed undo-and-TOC-navigation bug.