X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FCmdDef.cpp;h=e1a0e0066a440ca24ded23873e0d8d18fdebb27d;hb=1b56057e1f739551f2c410a4b0b3941246123531;hp=ed7cdbb08767f71e11ae9ef0844af4a583924887;hpb=9d0ea8aeff32833a90b3fe64df0c5518a9e241be;p=lyx.git diff --git a/src/CmdDef.cpp b/src/CmdDef.cpp index ed7cdbb087..e1a0e0066a 100644 --- a/src/CmdDef.cpp +++ b/src/CmdDef.cpp @@ -16,21 +16,18 @@ #include "Lexer.h" #include "support/debug.h" +#include "support/FileName.h" #include "support/filetools.h" #include "support/lstrings.h" #include +#include -using std::endl; -using std::string; +using namespace std; +using namespace lyx::support; namespace lyx { -using support::FileName; -using support::i18nLibFileSearch; -using support::trim; - - namespace { enum CmdDefTags { @@ -62,8 +59,6 @@ bool CmdDef::read(string const & def_file) return false; } - //LYXERR(Debug::KBMAP, "Reading def file:" << tmp); - bool error = false; while (lexrc.isOK()) { switch (lexrc.lex()) { @@ -133,47 +128,36 @@ bool CmdDef::read(string const & def_file) bool CmdDef::lock(string const & name, FuncRequest & func) { - if (cmdDefMap.empty()) - { + if (cmdDefMap.empty()) { func = FuncRequest::unknown; return false; } string const name2 = trim(name); - CmdDefMap::const_iterator pos = cmdDefMap.find(name2); - - if (pos == cmdDefMap.end()) - { - func = FuncRequest::unknown; + if (lockSet.find(name2) != lockSet.end()) { + func = FuncRequest::noaction; return false; } - if (pos->second->locked) - { - func = FuncRequest::noaction; + CmdDefMap::const_iterator pos = cmdDefMap.find(name2); + + if (pos == cmdDefMap.end()) { + func = FuncRequest::unknown; return false; } - pos->second->locked = true; - func = pos->second->func; + lockSet.insert(name2); + func = pos->second; return true; } void CmdDef::release(string const & name) { - if (cmdDefMap.empty()) - return; - string const name2 = trim(name); - CmdDefMap::const_iterator pos = cmdDefMap.find(name2); - - if (pos == cmdDefMap.end()) - return; - - pos->second->locked = false; + lockSet.erase(name2); } CmdDef::newCmdDefResult CmdDef::newCmdDef(string const & name, @@ -193,9 +177,7 @@ CmdDef::newCmdDefResult CmdDef::newCmdDef(string const & name, return CmdDefInvalid; } - boost::shared_ptr info; - info.reset(new CmdDefInfo(func)); - cmdDefMap[name2] = info; + cmdDefMap[name2] = func; return CmdDefOk; }