mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-31 15:46:16 +00:00
Fix bug 2186 (from Bo Peng):
* src/insets/insetbibtex.C (InsetBibtex::latex): mangle filename of bst file for "non-nice" .tex files * src/insets/insetgraphics.C (RemoveExtension): move ... * src/support/filetools.[Ch] (removeExtension): ... here git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13540 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7f6a274742
commit
768d523494
@ -50,6 +50,7 @@ using lyx::support::MakeAbsPath;
|
|||||||
using lyx::support::MakeRelPath;
|
using lyx::support::MakeRelPath;
|
||||||
using lyx::support::Path;
|
using lyx::support::Path;
|
||||||
using lyx::support::prefixIs;
|
using lyx::support::prefixIs;
|
||||||
|
using lyx::support::removeExtension;
|
||||||
using lyx::support::rtrim;
|
using lyx::support::rtrim;
|
||||||
using lyx::support::split;
|
using lyx::support::split;
|
||||||
using lyx::support::subst;
|
using lyx::support::subst;
|
||||||
@ -163,7 +164,8 @@ int InsetBibtex::latex(Buffer const & buffer, ostream & os,
|
|||||||
if (!runparams.inComment && !runparams.nice &&
|
if (!runparams.inComment && !runparams.nice &&
|
||||||
IsFileReadable(in_file)) {
|
IsFileReadable(in_file)) {
|
||||||
|
|
||||||
database = FileName(database).mangledFilename();
|
// mangledFilename() needs the extension
|
||||||
|
database = removeExtension(FileName(in_file).mangledFilename());
|
||||||
string const out_file = MakeAbsPath(database + ".bib",
|
string const out_file = MakeAbsPath(database + ".bib",
|
||||||
buffer.getMasterBuffer()->temppath());
|
buffer.getMasterBuffer()->temppath());
|
||||||
|
|
||||||
@ -207,12 +209,42 @@ int InsetBibtex::latex(Buffer const & buffer, ostream & os,
|
|||||||
int nlines = 0;
|
int nlines = 0;
|
||||||
|
|
||||||
if (!style.empty()) {
|
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{"
|
os << "\\bibliographystyle{"
|
||||||
<< latex_path(normalize_name(buffer, runparams, style, ".bst"))
|
<< latex_path(normalize_name(buffer, runparams, base, ".bst"))
|
||||||
<< "}\n";
|
<< "}\n";
|
||||||
nlines += 1;
|
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){
|
if (!db_out.empty() && buffer.params().use_bibtopic){
|
||||||
os << "\\begin{btSect}{" << db_out << "}\n";
|
os << "\\begin{btSect}{" << db_out << "}\n";
|
||||||
string btprint = getSecOptions();
|
string btprint = getSecOptions();
|
||||||
|
@ -101,6 +101,7 @@ using lyx::support::GetExtension;
|
|||||||
using lyx::support::IsFileReadable;
|
using lyx::support::IsFileReadable;
|
||||||
using lyx::support::latex_path;
|
using lyx::support::latex_path;
|
||||||
using lyx::support::OnlyFilename;
|
using lyx::support::OnlyFilename;
|
||||||
|
using lyx::support::removeExtension;
|
||||||
using lyx::support::rtrim;
|
using lyx::support::rtrim;
|
||||||
using lyx::support::subst;
|
using lyx::support::subst;
|
||||||
using lyx::support::Systemcall;
|
using lyx::support::Systemcall;
|
||||||
@ -119,15 +120,6 @@ using std::ostringstream;
|
|||||||
|
|
||||||
namespace {
|
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
|
/// Find the most suitable image format for images in \p format
|
||||||
/// Note that \p format may be unknown (i. e. an empty string)
|
/// Note that \p format may be unknown (i. e. an empty string)
|
||||||
string findTargetFormat(string const & format, OutputParams const & runparams)
|
string findTargetFormat(string const & format, OutputParams const & runparams)
|
||||||
@ -510,7 +502,7 @@ copyToDirIfNeeded(string const & file_in, string const & dir, bool zipped)
|
|||||||
// extension removed, because base.eps and base.eps.gz may
|
// extension removed, because base.eps and base.eps.gz may
|
||||||
// have different content but would get the same mangled
|
// have different content but would get the same mangled
|
||||||
// name in this case.
|
// name in this case.
|
||||||
string const base = RemoveExtension(unzippedFileName(file_in));
|
string const base = removeExtension(unzippedFileName(file_in));
|
||||||
string::size_type const ext_len = file_in.length() - base.length();
|
string::size_type const ext_len = file_in.length() - base.length();
|
||||||
mangled[mangled.length() - ext_len] = '.';
|
mangled[mangled.length() - ext_len] = '.';
|
||||||
}
|
}
|
||||||
@ -534,7 +526,7 @@ string const stripExtensionIfPossible(string const & file)
|
|||||||
lyx::support::EXCLUDE_EXTENSION);
|
lyx::support::EXCLUDE_EXTENSION);
|
||||||
if (contains(latex_name, '"'))
|
if (contains(latex_name, '"'))
|
||||||
return latex_name;
|
return latex_name;
|
||||||
return latex_path(RemoveExtension(file),
|
return latex_path(removeExtension(file),
|
||||||
lyx::support::PROTECT_EXTENSION,
|
lyx::support::PROTECT_EXTENSION,
|
||||||
lyx::support::ESCAPE_DOTS);
|
lyx::support::ESCAPE_DOTS);
|
||||||
}
|
}
|
||||||
@ -882,7 +874,7 @@ void InsetGraphics::validate(LaTeXFeatures & features) const
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
features.includeFile(graphic_label,
|
features.includeFile(graphic_label,
|
||||||
RemoveExtension(params().filename.absFilename()));
|
removeExtension(params().filename.absFilename()));
|
||||||
|
|
||||||
features.require("graphicx");
|
features.require("graphicx");
|
||||||
|
|
||||||
@ -890,9 +882,9 @@ void InsetGraphics::validate(LaTeXFeatures & features) const
|
|||||||
Buffer const * m_buffer = features.buffer().getMasterBuffer();
|
Buffer const * m_buffer = features.buffer().getMasterBuffer();
|
||||||
string basename =
|
string basename =
|
||||||
params().filename.outputFilename(m_buffer->filePath());
|
params().filename.outputFilename(m_buffer->filePath());
|
||||||
basename = RemoveExtension(basename);
|
basename = removeExtension(basename);
|
||||||
if(params().filename.isZipped())
|
if(params().filename.isZipped())
|
||||||
basename = RemoveExtension(basename);
|
basename = removeExtension(basename);
|
||||||
if (contains(basename, "."))
|
if (contains(basename, "."))
|
||||||
features.require("lyxdot");
|
features.require("lyxdot");
|
||||||
}
|
}
|
||||||
|
@ -744,6 +744,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 .)
|
/// Return the extension of the file (not including the .)
|
||||||
string const GetExtension(string const & name)
|
string const GetExtension(string const & name)
|
||||||
{
|
{
|
||||||
|
@ -154,6 +154,9 @@ std::string const AddPath(std::string const & path, std::string const & path2);
|
|||||||
std::string const
|
std::string const
|
||||||
ChangeExtension(std::string const & oldname, std::string const & extension);
|
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 .)
|
/// Return the extension of the file (not including the .)
|
||||||
std::string const GetExtension(std::string const & name);
|
std::string const GetExtension(std::string const & name);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user