# HG changeset patch # User Mike Becker # Date 1432816486 -7200 # Node ID 1e2b1005004c837571ec0521eee787e7ff02529b # Parent 5ffc2f23803fcbe1731a0f41efde296a192f72e1 fixed paranthsis ambiguity for logical and normal expressions diff -r 5ffc2f23803f -r 1e2b1005004c libidav/davqlparser.c --- a/libidav/davqlparser.c Thu May 28 14:15:32 2015 +0200 +++ b/libidav/davqlparser.c Thu May 28 14:34:46 2015 +0200 @@ -1162,33 +1162,29 @@ } // RULE: "(", LogicalExpression, ")" else if (token_is(token, DAVQL_TOKEN_OPENP)) { - token = token->next; - - int consumed = dav_parse_logical_expr(stmt, token, expr); - if (stmt->errorcode) { - return 0; - } - if (!consumed) { - dav_error_in_context(DAVQL_ERROR_MISSING_EXPR, - _error_missing_expr, stmt, token); - return 0; - } - - token = ucx_list_get(token, consumed); - - if (token_is(token, DAVQL_TOKEN_CLOSEP)) { - token = token->next; - return consumed + 2; + int consumed = dav_parse_logical_expr(stmt, token->next, expr); + if (consumed) { + token = ucx_list_get(token->next, consumed); + + if (token_is(token, DAVQL_TOKEN_CLOSEP)) { + token = token->next; + return consumed + 2; + } else { + dav_error_in_context(DAVQL_ERROR_MISSING_PAR, _error_missing_par, + stmt, token); + return 0; + } } else { - dav_error_in_context(DAVQL_ERROR_MISSING_PAR, _error_missing_par, - stmt, token); - return 0; + // don't handle errors here, we can also try a boolean primary + stmt->errorcode = 0; + if (stmt->errormessage) { + free(stmt->errormessage); + } } } + // RULE: BooleanPrimary - else { - return dav_parse_bool_prim(stmt, token, expr); - } + return dav_parse_bool_prim(stmt, token, expr); } static int dav_parse_logical_expr(DavQLStatement *stmt, UcxList *token,