Don't bring namespace lyx::support into the global namespace.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7646 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-09-03 12:56:52 +00:00
parent 9dcbe2910b
commit 2158ae655b
4 changed files with 47 additions and 38 deletions

View File

@ -1,3 +1,8 @@
2003-09-03 Angus Leeming <leeming@lyx.org>
* insetexternal.C: don't bring namespace lyx::support into the global
namespace.
2003-09-02 Martin Vermeer <martin.vermeer@hut.fi>
* insetbranch.C: Add Branch: to label

View File

@ -47,7 +47,7 @@
#include <cstdio>
#include <utility>
using namespace lyx::support;
namespace support = lyx::support;
using std::ostream;
using std::endl;
@ -80,8 +80,8 @@ InsetExternal::Params::Params()
: display(defaultDisplayType),
lyxscale(defaultLyxScale)
{
tempname = tempName(string(), "lyxext");
unlink(tempname);
tempname = support::tempName(string(), "lyxext");
support::unlink(tempname);
// must have an extension for the converter code to work correctly.
tempname += ".tmp";
}
@ -89,7 +89,7 @@ InsetExternal::Params::Params()
InsetExternal::Params::~Params()
{
unlink(tempname);
support::unlink(tempname);
}
@ -136,7 +136,7 @@ dispatch_result InsetExternal::localDispatch(FuncRequest const & cmd)
switch (cmd.action) {
case LFUN_EXTERNAL_EDIT: {
Assert(cmd.view());
support::Assert(cmd.view());
Buffer const & buffer = *cmd.view()->buffer();
InsetExternal::Params p;
@ -146,7 +146,7 @@ dispatch_result InsetExternal::localDispatch(FuncRequest const & cmd)
}
case LFUN_INSET_MODIFY: {
Assert(cmd.view());
support::Assert(cmd.view());
Buffer const & buffer = *cmd.view()->buffer();
InsetExternal::Params p;
@ -220,8 +220,8 @@ string const getScreenLabel(InsetExternal::Params const & params,
{
ExternalTemplate const * const ptr = getTemplatePtr(params);
if (!ptr)
return bformat(_("External template %1$s is not installed"),
params.templatename);
return support::bformat(_("External template %1$s is not installed"),
params.templatename);
return doSubstitution(params, buffer, ptr->guiName);
}
@ -500,7 +500,7 @@ void InsetExternal::updateExternal(string const & format,
return;
// Try and ascertain the file format from its contents.
from_format = getExtFromContents(from_file);
from_format = support::getExtFromContents(from_file);
if (from_format.empty())
return;
}
@ -518,7 +518,7 @@ void InsetExternal::updateExternal(string const & format,
if (external_in_tmpdir && !from_file.empty()) {
// We are running stuff through LaTeX
from_file = copyFileToDir(buf.tmppath, from_file);
from_file = support::copyFileToDir(buf.tmppath, from_file);
if (from_file.empty())
return;
}
@ -526,16 +526,17 @@ void InsetExternal::updateExternal(string const & format,
string const to_file = doSubstitution(params_, buf,
outputFormat.updateResult);
FileInfo fi(from_file);
support::FileInfo fi(from_file);
string abs_to_file = to_file;
if (!AbsolutePath(to_file))
abs_to_file = MakeAbsPath(to_file, OnlyPath(from_file));
FileInfo fi2(abs_to_file);
if (!support::AbsolutePath(to_file))
abs_to_file = support::MakeAbsPath(to_file,
support::OnlyPath(from_file));
support::FileInfo fi2(abs_to_file);
if (fi2.exist() && fi.exist() &&
difftime(fi2.getModificationTime(),
fi.getModificationTime()) >= 0) {
} else {
string const to_filebase = ChangeExtension(to_file, string());
string const to_filebase = support::ChangeExtension(to_file, string());
converters.convert(&buf, from_file, to_filebase,
from_format, to_format);
}
@ -551,34 +552,33 @@ string const doSubstitution(InsetExternal::Params const & params,
string result;
string const buffer_path = buffer.filePath();
string const filename = params.filename.outputFilename(buffer_path);
string const basename = ChangeExtension(filename, string());
string const filepath = OnlyPath(filename);
string const basename = support::ChangeExtension(filename, string());
string const filepath = support::OnlyPath(filename);
result = subst(s, "$$FName", filename);
result = subst(result, "$$Basename", basename);
result = subst(result, "$$FPath", filepath);
result = subst(result, "$$Tempname", params.tempname);
result = subst(result, "$$Sysdir", system_lyxdir());
result = support::subst(s, "$$FName", filename);
result = support::subst(result, "$$Basename", basename);
result = support::subst(result, "$$FPath", filepath);
result = support::subst(result, "$$Tempname", params.tempname);
result = support::subst(result, "$$Sysdir", support::system_lyxdir());
// Handle the $$Contents(filename) syntax
if (contains(result, "$$Contents(\"")) {
if (support::contains(result, "$$Contents(\"")) {
string::size_type const pos = result.find("$$Contents(\"");
string::size_type const end = result.find("\")", pos);
string const file = result.substr(pos + 12, end - (pos + 12));
string contents;
Path p(buffer.filePath());
if (!IsFileReadable(file)) {
#warning Is this really working as intended?
Path p(buffer.tmppath);
}
if (IsFileReadable(file))
contents = GetFileContents(file);
string const filepath = support::IsFileReadable(file) ?
buffer.filePath() : buffer.tmppath;
support::Path p(filepath);
result = subst(result,
("$$Contents(\"" + file + "\")").c_str(),
contents);
if (support::IsFileReadable(file))
contents = support::GetFileContents(file);
result = support::subst(result,
("$$Contents(\"" + file + "\")").c_str(),
contents);
}
return result;
@ -597,13 +597,13 @@ void editExternal(InsetExternal::Params const & params, Buffer const & buffer)
string const command = doSubstitution(params, buffer, et.editCommand);
Path p(buffer.filePath());
Forkedcall call;
support::Path p(buffer.filePath());
support::Forkedcall call;
if (lyxerr.debugging()) {
lyxerr << "Executing '" << command << "' in '"
<< buffer.filePath() << '\'' << endl;
}
call.startscript(Forkedcall::DontWait, command);
call.startscript(support::Forkedcall::DontWait, command);
}
} // namespace anon

View File

@ -1,3 +1,7 @@
2003-09-03 Angus Leeming <leeming@lyx.org>
* translator.h: Assert is in namespace lyx::support...
2003-08-02 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* Makefile.am: do not install path_defines.C in includes

View File

@ -50,7 +50,7 @@ public:
/// Find the mapping for the first argument
T2 const & find(T1 const & first) const {
Assert(!map.empty());
lyx::support::Assert(!map.empty());
// For explanation see the next find() function.
typename Map::const_iterator it =
@ -67,7 +67,7 @@ public:
/// Find the mapping for the second argument
T1 const & find(T2 const & second) const {
Assert(!map.empty());
lyx::support::Assert(!map.empty());
// The idea is as follows:
// find_if() will try to compare the data in the vector with