From: Pierre Habouzit Date: Mon, 13 Nov 2006 01:13:09 +0000 (+0100) Subject: more rationalization. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=d4321859bb9ce5b43fbd8303394cf98ae7720a38;p=apps%2Fmadmutt.git more rationalization. Signed-off-by: Pierre Habouzit --- diff --git a/alias.c b/alias.c index dc5084b..e0711c3 100644 --- a/alias.c +++ b/alias.c @@ -55,6 +55,27 @@ const address_t *alias_lookup(const alias_t *list, const char *s) return NULL; } +/* This routine looks to see if the user has an alias defined for the given + address. */ +const address_t *alias_reverse_lookup(const alias_t *list, const address_t *a) +{ + if (!a || !a->mailbox) + return NULL; + + for (; list; list = list->next) { + address_t *ap; + + /* cycle through all addresses if this is a group alias */ + for (ap = list->addr; ap; ap = ap->next) { + if (!ap->group && ap->mailbox + && !ascii_strcasecmp(ap->mailbox, a->mailbox)) + return ap; + } + } + + return NULL; +} + static int string_is_address(const char *str, const char *u, const char *d) { char buf[LONG_STRING]; @@ -349,30 +370,6 @@ void mutt_expand_aliases_env(ENVELOPE *env) /************* READ MARK *********************/ - -/* - * This routine looks to see if the user has an alias defined for the given - * address. - */ -address_t *alias_reverse_lookup (address_t * a) -{ - alias_t *t = Aliases; - address_t *ap; - - if (!a || !a->mailbox) - return NULL; - - for (; t; t = t->next) { - /* cycle through all addresses if this is a group alias */ - for (ap = t->addr; ap; ap = ap->next) { - if (!ap->group && ap->mailbox && - ascii_strcasecmp (ap->mailbox, a->mailbox) == 0) - return ap; - } - } - return 0; -} - /* alias_complete() -- alias completion routine * * given a partial alias, this routine attempts to fill in the alias diff --git a/alias.h b/alias.h index 244c0a4..88fb81d 100644 --- a/alias.h +++ b/alias.h @@ -31,13 +31,14 @@ DO_DELETE(alias_t, alias); DO_SLIST(alias_t, alias, alias_delete); const address_t *alias_lookup(const alias_t *list, const char *s); +const address_t *alias_reverse_lookup(const alias_t *list, const address_t *); + int mutt_addr_is_user(address_t *); address_t *mutt_get_address(ENVELOPE *, const char **); void mutt_create_alias(ENVELOPE *, address_t *); address_t *mutt_expand_aliases(address_t *); void mutt_expand_aliases_env(ENVELOPE *); -address_t *alias_reverse_lookup(address_t *); int mutt_alias_complete(char *, size_t); void mutt_alias_menu(char *, size_t, alias_t *); diff --git a/lib-lib/list.c b/lib-lib/list.c index 39ad786..83123a5 100644 --- a/lib-lib/list.c +++ b/lib-lib/list.c @@ -42,6 +42,7 @@ string_list_t *string_list_dup(const string_list_t *p) { return res; } +/* FIXME: b0rken API's, replace that at any cost */ string_list_t *mutt_add_list_n(string_list_t *head, const void *data, size_t len) { string_list_t *tmp; diff --git a/lib-lib/list.h b/lib-lib/list.h index 918eff8..2dac0f8 100644 --- a/lib-lib/list.h +++ b/lib-lib/list.h @@ -83,6 +83,7 @@ DO_SLIST(string_list_t, string, string_item_delete); string_list_t *string_list_dup(const string_list_t *); +/* FIXME: b0rken API's, replace that at any cost */ /* add an element to a list */ string_list_t *mutt_add_list_n(string_list_t*, const void*, size_t len); static inline string_list_t *mutt_add_list(string_list_t *head, const char *data) { @@ -90,6 +91,4 @@ static inline string_list_t *mutt_add_list(string_list_t *head, const char *data return mutt_add_list_n(head, data, len ? len + 1 : 0); } - - #endif /* MUTT_LIB_LIB_LIST_H */ diff --git a/pattern.c b/pattern.c index 8ace17a..868d7ab 100644 --- a/pattern.c +++ b/pattern.c @@ -1110,17 +1110,13 @@ mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, * - or we have an alias for current address * - or From: contains valid email address _and_ name has >= 2 fields */ - return (pat-> - not ^ (h->env && h->env->from && (mutt_addr_is_user (h->env->from) - || - (alias_reverse_lookup - (h->env->from) != NULL) - || (h->env->from->personal - && valid_realname (h->env-> - from-> - personal) - && h->env->from->mailbox) - ))); + return (h->env && h->env->from + && (mutt_addr_is_user(h->env->from) + || alias_reverse_lookup(Aliases, h->env->from) + || (h->env->from->personal + && valid_realname(h->env-> from->personal) + && h->env->from->mailbox) + )) ^ pat->not; #ifdef USE_NNTP case M_NEWSGROUPS: return (pat-> diff --git a/sort.c b/sort.c index c19ef98..38e9d87 100644 --- a/sort.c +++ b/sort.c @@ -94,7 +94,7 @@ const char *mutt_get_name (address_t * a) const char *name = ""; if (a) { - if (option (OPTREVALIAS) && (ali = alias_reverse_lookup (a)) + if (option (OPTREVALIAS) && (ali = alias_reverse_lookup(Aliases, a)) && ali->personal) name = ali->personal; else if (a->personal)