diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 00c71142ca..faa58981b8 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,12 @@ +2007-01-31 Georg 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. + 2007-01-19 Jean-Marc Lasgouttes * insetbranch.C (textString): implement, so that branches appear diff --git a/src/insets/insetbibtex.C b/src/insets/insetbibtex.C index ca3ef3a7df..eee7a7a786 100644 --- a/src/insets/insetbibtex.C +++ b/src/insets/insetbibtex.C @@ -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(); diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index e13fc6c013..bcf00ee033 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -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) diff --git a/src/support/ChangeLog b/src/support/ChangeLog index a4157c28e6..e21aba937b 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,7 @@ +2007-01-31 Georg Baum + + * filetools.C (RemoveExtension): new function. + 2007-01-08 Jean-Marc Lasgouttes * os_unix.C (canAutoOpenFile, autoOpenFile): on Mac OS X, use diff --git a/src/support/filetools.C b/src/support/filetools.C index 186522b029..cd696d509a 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -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) { diff --git a/src/support/filetools.h b/src/support/filetools.h index 9fb5a4f312..3036812b52 100644 --- a/src/support/filetools.h +++ b/src/support/filetools.h @@ -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); diff --git a/status.14x b/status.14x index 9ab8a4a6a3..3f50914ded 100644 --- a/status.14x +++ b/status.14x @@ -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.