dovecot: s/mask/pattern/
dovecot at dovecot.org
dovecot at dovecot.org
Sat Jun 30 00:48:21 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/f4dac54df44e
changeset: 5840:f4dac54df44e
user: Timo Sirainen <tss at iki.fi>
date: Fri Jun 29 21:21:44 2007 +0300
description:
s/mask/pattern/
diffstat:
2 files changed, 52 insertions(+), 50 deletions(-)
src/lib-imap/imap-match.c | 99 ++++++++++++++++++++++-----------------------
src/lib-imap/imap-match.h | 3 -
diffs (222 lines):
diff -r 978722ad6184 -r f4dac54df44e src/lib-imap/imap-match.c
--- a/src/lib-imap/imap-match.c Fri Jun 29 19:41:22 2007 +0300
+++ b/src/lib-imap/imap-match.c Fri Jun 29 21:21:44 2007 +0300
@@ -16,7 +16,7 @@ struct imap_match_glob {
const char *inboxcase_end;
char sep_char;
- char mask[1];
+ char pattern[1];
};
/* name of "INBOX" - must not have repeated substrings */
@@ -24,35 +24,36 @@ static const char inbox[] = "INBOX";
#define INBOXLEN (sizeof(inbox) - 1)
struct imap_match_glob *
-imap_match_init(pool_t pool, const char *mask, bool inboxcase, char separator)
+imap_match_init(pool_t pool, const char *pattern,
+ bool inboxcase, char separator)
{
struct imap_match_glob *glob;
const char *p, *inboxp;
char *dst;
/* +1 from struct */
- glob = p_malloc(pool, sizeof(struct imap_match_glob) + strlen(mask));
+ glob = p_malloc(pool, sizeof(struct imap_match_glob) + strlen(pattern));
glob->pool = pool;
glob->sep_char = separator;
- /* @UNSAFE: compress the mask */
- dst = glob->mask;
- while (*mask != '\0') {
- if (*mask == '*' || *mask == '%') {
+ /* @UNSAFE: compress the pattern */
+ dst = glob->pattern;
+ while (*pattern != '\0') {
+ if (*pattern == '*' || *pattern == '%') {
/* remove duplicate hierarchy wildcards */
- while (*mask == '%') mask++;
+ while (*pattern == '%') pattern++;
/* "%*" -> "*" */
- if (*mask == '*') {
+ if (*pattern == '*') {
/* remove duplicate wildcards */
- while (*mask == '*' || *mask == '%')
- mask++;
+ while (*pattern == '*' || *pattern == '%')
+ pattern++;
*dst++ = '*';
} else {
*dst++ = '%';
}
} else {
- *dst++ = *mask++;
+ *dst++ = *pattern++;
}
}
*dst++ = '\0';
@@ -61,7 +62,7 @@ imap_match_init(pool_t pool, const char
/* check if we could be comparing INBOX. */
inboxp = inbox;
glob->inboxcase = TRUE;
- p = glob->mask;
+ p = glob->pattern;
for (; *p != '\0' && *p != '*' && *p != separator; p++) {
if (*p != '%') {
inboxp = strchr(inboxp, i_toupper(*p));
@@ -93,43 +94,43 @@ void imap_match_deinit(struct imap_match
}
static inline bool cmp_chr(const struct imap_match_glob *glob,
- const char *data, char maskchr)
-{
- return *data == maskchr ||
+ const char *data, char patternchr)
+{
+ return *data == patternchr ||
(glob->inboxcase_end != NULL && data < glob->inboxcase_end &&
- i_toupper(*data) == i_toupper(maskchr));
+ i_toupper(*data) == i_toupper(patternchr));
}
static enum imap_match_result
match_sub(const struct imap_match_glob *glob, const char **data_p,
- const char **mask_p)
-{
- const char *mask, *data;
+ const char **pattern_p)
+{
+ const char *pattern, *data;
enum imap_match_result ret, best_ret;
- data = *data_p; mask = *mask_p;
-
- while (*mask != '\0' && *mask != '*' && *mask != '%') {
- if (!cmp_chr(glob, data, *mask)) {
- return *data == '\0' && *mask == glob->sep_char ?
+ data = *data_p; pattern = *pattern_p;
+
+ while (*pattern != '\0' && *pattern != '*' && *pattern != '%') {
+ if (!cmp_chr(glob, data, *pattern)) {
+ return *data == '\0' && *pattern == glob->sep_char ?
IMAP_MATCH_CHILDREN : IMAP_MATCH_NO;
}
- data++; mask++;
+ data++; pattern++;
}
best_ret = IMAP_MATCH_NO;
- while (*mask == '%') {
- mask++;
-
- if (*mask == '\0') {
+ while (*pattern == '%') {
+ pattern++;
+
+ if (*pattern == '\0') {
while (*data != '\0' && *data != glob->sep_char)
data++;
break;
}
while (*data != '\0') {
- if (cmp_chr(glob, data, *mask)) {
- ret = match_sub(glob, &data, &mask);
+ if (cmp_chr(glob, data, *pattern)) {
+ ret = match_sub(glob, &data, &pattern);
if (ret > 0)
break;
@@ -146,27 +147,27 @@ match_sub(const struct imap_match_glob *
}
}
- if (*mask != '*') {
- if (*data == '\0' && *mask != '\0')
- return *mask == glob->sep_char ?
+ if (*pattern != '*') {
+ if (*data == '\0' && *pattern != '\0')
+ return *pattern == glob->sep_char ?
IMAP_MATCH_CHILDREN : best_ret;
if (*data != '\0') {
return best_ret != IMAP_MATCH_NO ||
- *mask != '\0' || *data != glob->sep_char ?
+ *pattern != '\0' || *data != glob->sep_char ?
best_ret : IMAP_MATCH_PARENT;
}
}
*data_p = data;
- *mask_p = mask;
+ *pattern_p = pattern;
return IMAP_MATCH_YES;
}
enum imap_match_result
imap_match(struct imap_match_glob *glob, const char *data)
{
- const char *mask;
+ const char *pattern;
int ret;
if (glob->inboxcase &&
@@ -176,24 +177,24 @@ imap_match(struct imap_match_glob *glob,
else
glob->inboxcase_end = NULL;
- mask = glob->mask;
- if (*mask != '*') {
- if ((ret = match_sub(glob, &data, &mask)) <= 0)
+ pattern = glob->pattern;
+ if (*pattern != '*') {
+ if ((ret = match_sub(glob, &data, &pattern)) <= 0)
return ret;
- if (*mask == '\0')
+ if (*pattern == '\0')
return IMAP_MATCH_YES;
}
- while (*mask == '*') {
- mask++;
-
- if (*mask == '\0')
+ while (*pattern == '*') {
+ pattern++;
+
+ if (*pattern == '\0')
return IMAP_MATCH_YES;
while (*data != '\0') {
- if (cmp_chr(glob, data, *mask)) {
- if (match_sub(glob, &data, &mask) > 0)
+ if (cmp_chr(glob, data, *pattern)) {
+ if (match_sub(glob, &data, &pattern) > 0)
break;
}
@@ -201,6 +202,6 @@ imap_match(struct imap_match_glob *glob,
}
}
- return *data == '\0' && *mask == '\0' ?
+ return *data == '\0' && *pattern == '\0' ?
IMAP_MATCH_YES : IMAP_MATCH_CHILDREN;
}
diff -r 978722ad6184 -r f4dac54df44e src/lib-imap/imap-match.h
--- a/src/lib-imap/imap-match.h Fri Jun 29 19:41:22 2007 +0300
+++ b/src/lib-imap/imap-match.h Fri Jun 29 21:21:44 2007 +0300
@@ -19,7 +19,8 @@ struct imap_match_glob;
/* If inboxcase is TRUE, the "INBOX" string at the beginning of line is
compared case-insensitively */
struct imap_match_glob *
-imap_match_init(pool_t pool, const char *mask, bool inboxcase, char separator);
+imap_match_init(pool_t pool, const char *pattern,
+ bool inboxcase, char separator);
void imap_match_deinit(struct imap_match_glob **glob);
More information about the dovecot-cvs
mailing list