X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FCmdDef.cpp;h=08cd7dd6a928e01812904f2eb4e854bbfc97f2e0;hb=86bfa10abb57a0af7bbddc3af2c7cdb891c77203;hp=2055ed594995eda7fe238dd0eb69001527e88725;hpb=c88e7a7ef66a880b5fb6166ff9151001269bc7cd;p=lyx.git diff --git a/src/CmdDef.cpp b/src/CmdDef.cpp index 2055ed5949..08cd7dd6a9 100644 --- a/src/CmdDef.cpp +++ b/src/CmdDef.cpp @@ -12,6 +12,7 @@ #include "CmdDef.h" +#include "FuncRequest.h" #include "LyXAction.h" #include "Lexer.h" @@ -20,7 +21,6 @@ #include "support/filetools.h" #include "support/lstrings.h" -#include #include using namespace std; @@ -40,23 +40,20 @@ bool CmdDef::read(string const & def_file) { "\\define", BN_DEFINE } }; - Lexer lexrc(cmdDefTags); - if (lyxerr.debugging(Debug::PARSER)) - lexrc.printTable(lyxerr); - + Lexer lex(cmdDefTags); FileName const tmp(i18nLibFileSearch("commands", def_file, "def")); - lexrc.setFile(tmp); - if (!lexrc.isOK()) { - lyxerr << "CmdDef::read: cannot open def file:" - << tmp << endl; + lex.setContext("CmdDef::read"); + lex.setFile(tmp); + if (!lex.isOK()) { + LYXERR0( "CmdDef::read: cannot open def file:" << tmp); return false; } bool error = false; - while (lexrc.isOK()) { - switch (lexrc.lex()) { + while (lex.isOK()) { + switch (lex.lex()) { case Lexer::LEX_UNDEF: - lexrc.printError("Unknown tag `$$Token'"); + lex.printError("Unknown tag"); error = true; continue; case Lexer::LEX_FEOF: @@ -65,18 +62,18 @@ bool CmdDef::read(string const & def_file) { string name, def; - if (lexrc.next()) { - name = lexrc.getString(); + if (lex.next()) { + name = lex.getString(); } else { - lexrc.printError("BN_DEFINE: Missing command name"); + lex.printError("BN_DEFINE: Missing command name"); error = true; break; } - if (lexrc.next(true)) { - def = lexrc.getString(); + if (lex.next(true)) { + def = lex.getString(); } else { - lexrc.printError("BN_DEFINE: missing command definition"); + lex.printError("BN_DEFINE: missing command definition"); error = true; break; } @@ -84,15 +81,15 @@ bool CmdDef::read(string const & def_file) newCmdDefResult e = newCmdDef(name, def); switch (e) { case CmdDefNameEmpty: - lexrc.printError("BN_DEFINE: Command name is empty"); + lex.printError("BN_DEFINE: Command name is empty"); error = true; break; case CmdDefExists: - lexrc.printError("BN_DEFINE: Command `" + name + "' already defined"); + lex.printError("BN_DEFINE: Command `" + name + "' already defined"); error = true; break; case CmdDefInvalid: - lexrc.printError("BN_DEFINE: Command definition for `" + name + "' is not valid"); + lex.printError("BN_DEFINE: Command definition for `" + name + "' is not valid"); error = true; break; case CmdDefOk: @@ -102,11 +99,11 @@ bool CmdDef::read(string const & def_file) break; } case BN_DEFFILE: - if (lexrc.next()) { - string const tmp = lexrc.getString(); - error |= !read(tmp); + if (lex.next()) { + string const stmp = lex.getString(); + error |= !read(stmp); } else { - lexrc.printError("BN_DEFFILE: Missing file name"); + lex.printError("BN_DEFFILE: Missing file name"); error = true; break; @@ -116,8 +113,7 @@ bool CmdDef::read(string const & def_file) } if (error) - lyxerr << "CmdDef::read: error while reading def file:" - << tmp << endl; + LYXERR0("CmdDef::read: error while reading def file:" << tmp); return !error; } @@ -156,20 +152,20 @@ void CmdDef::release(string const & name) } -CmdDef::newCmdDefResult CmdDef::newCmdDef(string const & name, - string const & def) +CmdDef::newCmdDefResult CmdDef::newCmdDef(string const & name, + string const & def) { string const name2 = trim(name); - if (name2.empty()) + if (name2.empty()) return CmdDefNameEmpty; if (cmdDefMap.find(name) != cmdDefMap.end()) return CmdDefExists; FuncRequest func = lyxaction.lookupFunc(def); - if (func.action == LFUN_NOACTION - || func.action == LFUN_UNKNOWN_ACTION) { + if (func.action() == LFUN_NOACTION + || func.action() == LFUN_UNKNOWN_ACTION) { return CmdDefInvalid; }