summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-01-23 03:26:47 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-01-23 03:26:47 -0400
commit7ee583a448a3ddf343cc609c62f17da7e9e82090 (patch)
treeda7e7bbc022320a10ad219f997f6ec1fb594fc4a /src
parentf0d13734b40d4c671a20340deeb9b2c5faa09037 (diff)
downloadledger-7ee583a448a3ddf343cc609c62f17da7e9e82090.tar.gz
ledger-7ee583a448a3ddf343cc609c62f17da7e9e82090.tar.bz2
ledger-7ee583a448a3ddf343cc609c62f17da7e9e82090.zip
Correctly handle "bare parentheses" in the command regexps.
Diffstat (limited to 'src')
-rw-r--r--src/report.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/report.cc b/src/report.cc
index 50a199f4..2dfc9d76 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -323,44 +323,51 @@ namespace {
{
std::ostringstream expr;
bool append_and = false;
+ bool only_parenthesis;
while (begin != end) {
const string& arg((*begin).as_string());
+ const char * p = arg.c_str();
bool parse_argument = true;
- if (arg == "not") {
+ if (arg == "not" || arg == "NOT") {
expr << " ! ";
parse_argument = false;
append_and = false;
}
- else if (arg == "and") {
+ else if (arg == "and" || arg == "AND") {
expr << " & ";
parse_argument = false;
append_and = false;
}
- else if (arg == "or") {
+ else if (arg == "or" || arg == "OR") {
expr << " | ";
parse_argument = false;
append_and = false;
}
else if (append_and) {
- expr << " & ";
+ if (! only_parenthesis)
+ expr << " & ";
}
else {
append_and = true;
}
if (parse_argument) {
- const char * p = arg.c_str();
-
bool in_prefix = true;
bool in_suffix = false;
bool found_specifier = false;
bool saw_tag_char = false;
+ only_parenthesis = true;
+
for (const char * c = p; *c != '\0'; c++) {
bool consumed = false;
+
+ if (*c != '(' && *c != ')')
+ only_parenthesis = false;
+
if (in_prefix) {
switch (*c) {
case '(':