From 02aaf6e3ec9f75c9d69bd82ee690821d69eba6e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Fri, 13 May 2016 15:02:29 +0000 Subject: [PATCH] if can have a variable test or a content check --- bootstrap.sh | 2 +- src/commands.hxx | 77 ++++++++++++++++++++++++++++++++++-------------- 2 files changed, 56 insertions(+), 23 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index 9b53b8b..de16e6d 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -845,7 +845,7 @@ if testtag AX_USE_DOXYGEN; then doxyreplace PROJECT_NAME "@PACKAGE_NAME@" doxyreplace PROJECT_NUMBER "@PACKAGE_VERSION@" doxyreplace PROJECT_BRIEF "@DESCRIPTION@" - doxyreplace PROJECT_LOGO "@top_srcdir@/@PACKACE_LOGO@" + doxyreplace PROJECT_LOGO "@top_srcdir@/@PACKAGE_LOGO@" doxyreplace INLINE_INHERITED_MEMB YES doxyreplace MULTILINE_CPP_IS_BRIEF YES doxyreplace TAB_SIZE 2 diff --git a/src/commands.hxx b/src/commands.hxx index 8df7b97..7ffb296 100644 --- a/src/commands.hxx +++ b/src/commands.hxx @@ -2084,16 +2084,28 @@ class If: public Command { " \n" " \n" " <...>\n" + "\n\n"+ + tag()+" -> \n" + " \n" + " \n" + " <...>\n" + "else\n" + " \n" + " \n" + " <...>\n" "\n\n" "Execute commands conditionally. " + "The first variant compares a variable to a value. " "The comparision can be = ^ . ~ < >, " "which means equal, different, contains, match, " "less (as integer), bigger (as integer). " "Match allows a regular expression. " + "The second variant checks for a text in a selector, " + "similar to command exists. " "There is an optional else part."; } QString command() const { - return tag()+" "+_variable+" "+QString(_cmp)+" "+_value + return tag()+" "+_variable+" "+_cmp+" "+_value +(_script.get()?"\n"+_script->print().join("\n "):""); } std::shared_ptr parse(Script*, QString args, @@ -2101,10 +2113,17 @@ class If: public Command { int indent) { std::shared_ptr cmd(new If()); int pos(args.indexOf(QRegularExpression("[=^.~<>]"))); - if (pos<0) throw BadArgument(tag()+" needs a comparision, not: "+args); + int len(1); + if (args.contains("->")) { + pos = args.indexOf("->"); + len = 2; + cmd->_cmp = "->"; + } else { + if (pos<0) throw BadArgument(tag()+" needs a comparision, not: "+args); + cmd->_cmp = args[pos]; + } cmd->_variable = args.left(pos).trimmed(); - cmd->_cmp = args[pos].toLatin1(); - cmd->_value = args.mid(pos+1).trimmed(); + cmd->_value = args.mid(pos+len).trimmed(); cmd->_script = std::shared_ptr