Remove the 'running' booleans quit and optional

Reason for this 'cleanup' is the strange "optional = false" lines at the
end of the "case md_item" and "case md_subitem". Then, it is nicer to
directly use the value of the switch to be the running variable and to use
this to determine whether an item is optional and whether we should quit.
This commit is contained in:
Vincent van Ravesteijn 2013-05-13 11:21:53 +02:00
parent a033b88a37
commit ed5585966b

View File

@ -517,14 +517,10 @@ void MenuDefinition::read(Lexer & lex)
lex.pushTable(menutags);
lex.setContext("MenuDefinition::read: ");
bool quit = false;
bool optional = false;
while (lex.isOK() && !quit) {
switch (lex.lex()) {
int md_type = 0;
while (lex.isOK() && md_type != md_endmenu) {
switch (md_type = lex.lex()) {
case md_optitem:
optional = true;
// fallback to md_item
case md_item: {
lex.next(true);
docstring const name = translateIfPossible(lex.getDocString());
@ -534,8 +530,8 @@ void MenuDefinition::read(Lexer & lex)
FuncRequest::Origin origin = FuncRequest::MENU;
if (name_.startsWith("context-toc-"))
origin = FuncRequest::TOC;
bool const optional = (md_type == md_optitem);
add(MenuItem(MenuItem::Command, toqstr(name), func, QString(), optional, origin));
optional = false;
break;
}
@ -656,21 +652,18 @@ void MenuDefinition::read(Lexer & lex)
break;
case md_optsubmenu:
optional = true;
// fallback to md_submenu
case md_submenu: {
lex.next(true);
docstring const mlabel = translateIfPossible(lex.getDocString());
lex.next(true);
docstring const mname = lex.getDocString();
bool const optional = (md_type == md_optsubmenu);
add(MenuItem(MenuItem::Submenu,
toqstr(mlabel), toqstr(mname), QString(), optional));
optional = false;
break;
}
case md_endmenu:
quit = true;
break;
default: