C++ compilers don't like the "not".
break;
case SEARCH_MAILBOX:
case SEARCH_MAILBOX_GLOB:
- if (args->not) {
+ if (args->match_not) {
array_clear(patterns);
return 0;
}
} else {
/* $ not set yet, match nothing */
search_args->args->type = SEARCH_ALL;
- search_args->args->not = TRUE;
+ search_args->args->match_not = TRUE;
}
*search_args_r = search_args;
return 1;
match = strcmp(mail_guid_128_to_string(metadata.guid),
arg->value.str) == 0;
- if (match != arg->not)
+ if (match != arg->match_not)
arg->match_always = TRUE;
else
arg->nonmatch_always = TRUE;
ctx->have_mailbox_args = TRUE;
break;
case SEARCH_ALL:
- if (!arg->not)
+ if (!arg->match_not)
arg->match_always = TRUE;
else
arg->nonmatch_always = TRUE;
if (arg->value.date_type != MAIL_SEARCH_DATE_TYPE_SENT)
break;
- if (arg->not) {
+ if (arg->match_not) {
/* date header not found, so we match only for
NOT searches */
ARG_SET_RESULT(arg, 0);
return mail_search_args_foreach(args, search_body, &body_ctx);
}
-static bool search_msgset_fix_limits(unsigned int messages_count,
- ARRAY_TYPE(seq_range) *seqset, bool not)
+static bool
+search_msgset_fix_limits(unsigned int messages_count,
+ ARRAY_TYPE(seq_range) *seqset, bool match_not)
{
struct seq_range *range;
unsigned int count;
seq_range_array_remove_range(seqset, messages_count + 1,
(uint32_t)-1);
}
- if (!not)
+ if (!match_not)
return array_count(seqset) > 0;
else {
/* if all messages are in the range, it can't match */
}
}
-static void search_msgset_fix(unsigned int messages_count,
- ARRAY_TYPE(seq_range) *seqset,
- uint32_t *seq1_r, uint32_t *seq2_r, bool not)
+static void
+search_msgset_fix(unsigned int messages_count,
+ ARRAY_TYPE(seq_range) *seqset,
+ uint32_t *seq1_r, uint32_t *seq2_r, bool match_not)
{
const struct seq_range *range;
unsigned int count;
uint32_t min_seq, max_seq;
- if (!search_msgset_fix_limits(messages_count, seqset, not)) {
+ if (!search_msgset_fix_limits(messages_count, seqset, match_not)) {
*seq1_r = (uint32_t)-1;
*seq2_r = 0;
return;
}
range = array_get(seqset, &count);
- if (!not) {
+ if (!match_not) {
min_seq = range[0].seq1;
max_seq = range[count-1].seq2;
} else {
switch (args->type) {
case SEARCH_SUB:
- i_assert(!args->not);
+ i_assert(!args->match_not);
search_parse_msgset_args(messages_count,
args->value.subargs,
&seq1, &seq2);
break;
case SEARCH_OR:
- i_assert(!args->not);
+ i_assert(!args->match_not);
search_or_parse_msgset_args(messages_count,
args->value.subargs,
&seq1, &seq2);
break;
case SEARCH_SEQSET:
search_msgset_fix(messages_count, &args->value.seqset,
- &seq1, &seq2, args->not);
+ &seq1, &seq2, args->match_not);
break;
default:
break;
for (; args != NULL; args = args->next) {
switch (args->type) {
case SEARCH_SUB:
- i_assert(!args->not);
+ i_assert(!args->match_not);
search_parse_msgset_args(messages_count,
args->value.subargs,
seq1_r, seq2_r);
case SEARCH_OR:
/* go through our children and use the widest seqset
range */
- i_assert(!args->not);
+ i_assert(!args->match_not);
search_or_parse_msgset_args(messages_count,
args->value.subargs,
seq1_r, seq2_r);
break;
case SEARCH_SEQSET:
search_msgset_fix(messages_count, &args->value.seqset,
- seq1_r, seq2_r, args->not);
+ seq1_r, seq2_r, args->match_not);
break;
default:
break;
for (; args != NULL; args = args->next) {
if (args->type != SEARCH_FLAGS) {
if (args->type == SEARCH_ALL) {
- if (args->not)
+ if (args->match_not)
return FALSE;
}
continue;
}
if ((args->value.flags & MAIL_SEEN) != 0) {
/* SEEN with 0 seen? */
- if (!args->not && hdr->seen_messages_count == 0)
+ if (!args->match_not && hdr->seen_messages_count == 0)
return FALSE;
if (hdr->seen_messages_count == hdr->messages_count) {
/* UNSEEN with all seen? */
- if (args->not)
+ if (args->match_not)
return FALSE;
/* SEEN with all seen */
args->match_always = TRUE;
- } else if (args->not) {
+ } else if (args->match_not) {
/* UNSEEN with lowwater limiting */
search_limit_lowwater(ctx,
hdr->first_unseen_uid_lowwater, seq1);
}
if ((args->value.flags & MAIL_DELETED) != 0) {
/* DELETED with 0 deleted? */
- if (!args->not && hdr->deleted_messages_count == 0)
+ if (!args->match_not &&
+ hdr->deleted_messages_count == 0)
return FALSE;
if (hdr->deleted_messages_count ==
hdr->messages_count) {
/* UNDELETED with all deleted? */
- if (args->not)
+ if (args->match_not)
return FALSE;
/* DELETED with all deleted */
args->match_always = TRUE;
- } else if (!args->not) {
+ } else if (!args->match_not) {
/* DELETED with lowwater limiting */
search_limit_lowwater(ctx,
hdr->first_deleted_uid_lowwater, seq1);
return -1;
}
- if (root->type == SEARCH_SUB && !root->not) {
+ if (root->type == SEARCH_SUB && !root->match_not) {
/* simple SUB root */
args->args = root->value.subargs;
} else {
if (mail_search_build_key(ctx, ctx->parent, &sarg) < 0)
return NULL;
- sarg->not = !sarg->not;
+ sarg->match_not = !sarg->match_not;
return sarg;
}
struct mail_search_arg *sarg; \
sarg = mail_search_build_new(ctx, SEARCH_FLAGS); \
sarg->value.flags = _flag; \
- sarg->not = _not; \
+ sarg->match_not = _not; \
return sarg; \
}
CALLBACK_FLAG(answered, MAIL_ANSWERED, FALSE);
sarg = imap_search_keyword(ctx);
if (sarg != NULL)
- sarg->not = TRUE;
+ sarg->match_not = TRUE;
return sarg;
}
new_arg = p_new(pool, struct mail_search_arg, 1);
new_arg->type = arg->type;
- new_arg->not = arg->not;
+ new_arg->match_not = arg->match_not;
new_arg->match_always = arg->match_always;
new_arg->nonmatch_always = arg->nonmatch_always;
new_arg->value.search_flags = arg->value.search_flags;
subarg = subarg->next;
}
- if (arg->not && arg->result != -1)
+ if (arg->match_not && arg->result != -1)
arg->result = !arg->result;
} else if (arg->type == SEARCH_OR) {
/* OR-list of conditions */
subarg = subarg->next;
}
- if (arg->not && arg->result != -1)
+ if (arg->match_not && arg->result != -1)
arg->result = !arg->result;
} else {
/* just a single condition */
return TRUE;
case SEARCH_MAILBOX:
ret = strcmp(arg->value.str, vname) == 0;
- return ret != arg->not;
+ return ret != arg->match_not;
case SEARCH_MAILBOX_GLOB: {
T_BEGIN {
struct imap_match_glob *glob;
arg->value.str, TRUE, sep);
ret = imap_match(glob, vname) == IMAP_MATCH_YES;
} T_END;
- return ret != arg->not;
+ return ret != arg->match_not;
}
default:
break;
prev_flags_arg = prev_not_flags_arg = NULL;
prev_kw_arg = prev_not_kw_arg = NULL;
while (args != NULL) {
- if (args->not && (args->type == SEARCH_SUB ||
- args->type == SEARCH_OR)) {
+ if (args->match_not && (args->type == SEARCH_SUB ||
+ args->type == SEARCH_OR)) {
/* neg(p and q and ..) == neg(p) or neg(q) or ..
neg(p or q or ..) == neg(p) and neg(q) and .. */
args->type = args->type == SEARCH_SUB ?
SEARCH_OR : SEARCH_SUB;
- args->not = FALSE;
+ args->match_not = FALSE;
sub = args->value.subargs;
do {
- sub->not = !sub->not;
+ sub->match_not = !sub->match_not;
sub = sub->next;
} while (sub != NULL);
}
}
/* merge all flags arguments */
- if (args->type == SEARCH_FLAGS && !args->not && parent_and) {
+ if (args->type == SEARCH_FLAGS &&
+ !args->match_not && parent_and) {
if (prev_flags_arg == NULL)
prev_flags_arg = args;
else {
args = args->next;
continue;
}
- } else if (args->type == SEARCH_FLAGS && args->not &&
+ } else if (args->type == SEARCH_FLAGS && args->match_not &&
!parent_and) {
if (prev_not_flags_arg == NULL)
prev_not_flags_arg = args;
}
/* merge all keywords arguments */
- if (args->type == SEARCH_KEYWORDS && !args->not && parent_and) {
+ if (args->type == SEARCH_KEYWORDS &&
+ !args->match_not && parent_and) {
if (prev_kw_arg == NULL)
prev_kw_arg = args;
else {
args = args->next;
continue;
}
- } else if (args->type == SEARCH_KEYWORDS && args->not &&
- !parent_and) {
+ } else if (args->type == SEARCH_KEYWORDS &&
+ args->match_not && !parent_and) {
if (prev_not_kw_arg == NULL)
prev_not_kw_arg = args;
else {
const struct mail_search_arg *arg2)
{
if (arg1->type != arg2->type ||
- arg1->not != arg2->not)
+ arg1->match_not != arg2->match_not)
return FALSE;
switch (arg1->type) {
void *context;
const char *hdr_field_name; /* for SEARCH_HEADER* */
- unsigned int not:1;
+ unsigned int match_not:1; /* result = !result */
unsigned int match_always:1; /* result = 1 always */
unsigned int nonmatch_always:1; /* result = 0 always */
#define ARG_SET_RESULT(arg, res) \
STMT_START { \
- (arg)->result = !(arg)->not ? (res) : \
+ (arg)->result = !(arg)->match_not ? (res) : \
(res) == -1 ? -1 : !(res); \
} STMT_END
const char *vname, char sep);
/* Simplify/optimize search arguments. Afterwards all OR/SUB args are
- guaranteed to have not=FALSE. */
+ guaranteed to have match_not=FALSE. */
void mail_search_args_simplify(struct mail_search_args *args);
/* Serialization for search args' results. */
/* can't filter this */
return 0;
}
- if (arg->not)
+ if (arg->match_not)
flags |= FTS_LOOKUP_FLAG_INVERT;
if (!fctx->refreshed) {
return FALSE;
/* avoid NOTs */
- if (old_arg->not && !new_arg->not)
+ if (old_arg->match_not && !new_arg->match_not)
return TRUE;
- if (!old_arg->not && new_arg->not)
+ if (!old_arg->match_not && new_arg->match_not)
return FALSE;
/* prefer not to use headers. they have a larger possibility of