Correctly handle "bare parentheses" in the command regexps.
This commit is contained in:
parent
f0d13734b4
commit
7ee583a448
1 changed files with 13 additions and 6 deletions
|
|
@ -323,44 +323,51 @@ namespace {
|
||||||
{
|
{
|
||||||
std::ostringstream expr;
|
std::ostringstream expr;
|
||||||
bool append_and = false;
|
bool append_and = false;
|
||||||
|
bool only_parenthesis;
|
||||||
|
|
||||||
while (begin != end) {
|
while (begin != end) {
|
||||||
const string& arg((*begin).as_string());
|
const string& arg((*begin).as_string());
|
||||||
|
const char * p = arg.c_str();
|
||||||
|
|
||||||
bool parse_argument = true;
|
bool parse_argument = true;
|
||||||
|
|
||||||
if (arg == "not") {
|
if (arg == "not" || arg == "NOT") {
|
||||||
expr << " ! ";
|
expr << " ! ";
|
||||||
parse_argument = false;
|
parse_argument = false;
|
||||||
append_and = false;
|
append_and = false;
|
||||||
}
|
}
|
||||||
else if (arg == "and") {
|
else if (arg == "and" || arg == "AND") {
|
||||||
expr << " & ";
|
expr << " & ";
|
||||||
parse_argument = false;
|
parse_argument = false;
|
||||||
append_and = false;
|
append_and = false;
|
||||||
}
|
}
|
||||||
else if (arg == "or") {
|
else if (arg == "or" || arg == "OR") {
|
||||||
expr << " | ";
|
expr << " | ";
|
||||||
parse_argument = false;
|
parse_argument = false;
|
||||||
append_and = false;
|
append_and = false;
|
||||||
}
|
}
|
||||||
else if (append_and) {
|
else if (append_and) {
|
||||||
expr << " & ";
|
if (! only_parenthesis)
|
||||||
|
expr << " & ";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
append_and = true;
|
append_and = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse_argument) {
|
if (parse_argument) {
|
||||||
const char * p = arg.c_str();
|
|
||||||
|
|
||||||
bool in_prefix = true;
|
bool in_prefix = true;
|
||||||
bool in_suffix = false;
|
bool in_suffix = false;
|
||||||
bool found_specifier = false;
|
bool found_specifier = false;
|
||||||
bool saw_tag_char = false;
|
bool saw_tag_char = false;
|
||||||
|
|
||||||
|
only_parenthesis = true;
|
||||||
|
|
||||||
for (const char * c = p; *c != '\0'; c++) {
|
for (const char * c = p; *c != '\0'; c++) {
|
||||||
bool consumed = false;
|
bool consumed = false;
|
||||||
|
|
||||||
|
if (*c != '(' && *c != ')')
|
||||||
|
only_parenthesis = false;
|
||||||
|
|
||||||
if (in_prefix) {
|
if (in_prefix) {
|
||||||
switch (*c) {
|
switch (*c) {
|
||||||
case '(':
|
case '(':
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue