]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Renamed mail_search_arg.not to match_not.
authorTimo Sirainen <tss@iki.fi>
Sat, 2 Jul 2011 04:08:26 +0000 (07:08 +0300)
committerTimo Sirainen <tss@iki.fi>
Sat, 2 Jul 2011 04:08:26 +0000 (07:08 +0300)
C++ compilers don't like the "not".

src/doveadm/doveadm-mail-list-iter.c
src/imap/imap-search-args.c
src/lib-storage/index/index-search.c
src/lib-storage/mail-search-build.c
src/lib-storage/mail-search-register-imap.c
src/lib-storage/mail-search.c
src/lib-storage/mail-search.h
src/plugins/fts/fts-search.c

index 5a0d621bfea61311b33ece963c1ce5189d7dad9c..0ef11d091b511ec52129e88fdf13aebe585816f3 100644 (file)
@@ -37,7 +37,7 @@ search_args_get_mailbox_patterns(const struct mail_search_arg *args,
                        break;
                case SEARCH_MAILBOX:
                case SEARCH_MAILBOX_GLOB:
-                       if (args->not) {
+                       if (args->match_not) {
                                array_clear(patterns);
                                return 0;
                        }
index 677836b4311e5761937d4428496882e81020037f..dfa2943f701338045e60041da7f30cdcdaaea128 100644 (file)
@@ -177,7 +177,7 @@ static int imap_search_get_searchres(struct client_command_context *cmd,
        } 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;
index a18d03e1962c34a687fb2ed2f67c880a600f601c..bc781dde535769194a73153ae2c0faf04f8f4517 100644 (file)
@@ -90,7 +90,7 @@ static void search_init_arg(struct mail_search_arg *arg,
 
                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;
@@ -100,7 +100,7 @@ static void search_init_arg(struct mail_search_arg *arg,
                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;
@@ -514,7 +514,7 @@ static void search_header_unmatch(struct mail_search_arg *arg,
                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);
@@ -689,8 +689,9 @@ static int search_arg_match_text(struct mail_search_arg *args,
        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;
@@ -709,7 +710,7 @@ static bool search_msgset_fix_limits(unsigned int messages_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 */
@@ -719,22 +720,23 @@ static bool search_msgset_fix_limits(unsigned int messages_count,
        }
 }
 
-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 {
@@ -765,20 +767,20 @@ static void search_or_parse_msgset_args(unsigned int messages_count,
 
                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;
@@ -809,7 +811,7 @@ static void search_parse_msgset_args(unsigned int messages_count,
        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);
@@ -817,14 +819,14 @@ static void search_parse_msgset_args(unsigned int messages_count,
                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;
@@ -856,24 +858,24 @@ static bool search_limit_by_flags(struct index_search_context *ctx,
        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);
@@ -881,18 +883,19 @@ static bool search_limit_by_flags(struct index_search_context *ctx,
                }
                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);
index f80dc090bdc27614f1e534593b39d0972ae2d908..51257350f9a209a9af0c934a910e839ac81369a4 100644 (file)
@@ -164,7 +164,7 @@ int mail_search_build(struct mail_search_register *reg,
                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 {
index 04731fa294ca1c382978a9f58b0e3e7e59ec2893..cf15db52a632e143c90283a0cbdd69e0983fa7d6 100644 (file)
@@ -44,7 +44,7 @@ imap_search_not(struct mail_search_build_context *ctx)
        if (mail_search_build_key(ctx, ctx->parent, &sarg) < 0)
                return NULL;
 
-       sarg->not = !sarg->not;
+       sarg->match_not = !sarg->match_not;
        return sarg;
 }
 
@@ -113,7 +113,7 @@ imap_search_##_func(struct mail_search_build_context *ctx) \
        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);
@@ -150,7 +150,7 @@ imap_search_unkeyword(struct mail_search_build_context *ctx)
 
        sarg = imap_search_keyword(ctx);
        if (sarg != NULL)
-               sarg->not = TRUE;
+               sarg->match_not = TRUE;
        return sarg;
 }
 
index 3c38ddc04a018643eaef594c9fca4a540d1ec86e..ef5f1ee290a0dc91995a516963a3e04b40a58772 100644 (file)
@@ -265,7 +265,7 @@ mail_search_arg_dup_one(pool_t pool, const struct mail_search_arg *arg)
 
        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;
@@ -404,7 +404,7 @@ static void search_arg_foreach(struct mail_search_arg *arg,
 
                        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 */
@@ -426,7 +426,7 @@ static void search_arg_foreach(struct mail_search_arg *arg,
 
                        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 */
@@ -554,7 +554,7 @@ mail_search_args_match_mailbox_arg(const struct mail_search_arg *arg,
                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;
@@ -563,7 +563,7 @@ mail_search_args_match_mailbox_arg(const struct mail_search_arg *arg,
                                               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;
@@ -629,16 +629,16 @@ mail_search_args_simplify_sub(struct mailbox *box,
        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);
                }
@@ -665,7 +665,8 @@ mail_search_args_simplify_sub(struct mailbox *box,
                }
 
                /* 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 {
@@ -675,7 +676,7 @@ mail_search_args_simplify_sub(struct mailbox *box,
                                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;
@@ -689,7 +690,8 @@ mail_search_args_simplify_sub(struct mailbox *box,
                }
 
                /* 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 {
@@ -701,8 +703,8 @@ mail_search_args_simplify_sub(struct mailbox *box,
                                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 {
@@ -803,7 +805,7 @@ static bool mail_search_arg_one_equals(const struct mail_search_arg *arg1,
                                       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) {
index 20789a2c94452240468cac18e0740111d66f7d85..8c7965e67f64612da6c17c8f4bd9190da539b359 100644 (file)
@@ -91,7 +91,7 @@ struct mail_search_arg {
 
         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 */
 
@@ -111,7 +111,7 @@ struct mail_search_args {
 
 #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
 
@@ -173,7 +173,7 @@ bool mail_search_args_match_mailbox(struct mail_search_args *args,
                                    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. */
index a34df1ab99b80611b2eaf751db58debded4e5839..e9c5e5f2033b7771bef3f62417d7ac51c8c5ec94 100644 (file)
@@ -69,7 +69,7 @@ static int fts_search_lookup_arg(struct fts_search_context *fctx,
                /* can't filter this */
                return 0;
        }
-       if (arg->not)
+       if (arg->match_not)
                flags |= FTS_LOOKUP_FLAG_INVERT;
 
        if (!fctx->refreshed) {
@@ -131,9 +131,9 @@ static bool arg_is_better(const struct mail_search_arg *new_arg,
                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