From: Pietro Cerutti Date: Fri, 25 May 2018 10:38:51 +0000 (+0000) Subject: Move group.[ch] to mutt/ X-Git-Tag: 2019-10-25~442^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b61adb96aed9b8d5899712b5858fc59001d3e6a0;p=neomutt Move group.[ch] to mutt/ --- diff --git a/Makefile.autosetup b/Makefile.autosetup index 3421e8224..9b7addd81 100644 --- a/Makefile.autosetup +++ b/Makefile.autosetup @@ -64,7 +64,7 @@ NEOMUTT= neomutt$(EXEEXT) NEOMUTTOBJS= account.o addrbook.o alias.o bcache.o browser.o color.o commands.o \ complete.o compose.o compress.o conststrings.o copy.o \ curs_lib.o edit.o editmsg.o enriched.o enter.o \ - filter.o flags.o git_ver.o group.o handler.o hdrline.o help.o hook.o \ + filter.o flags.o git_ver.o handler.o hdrline.o help.o hook.o \ index.o init.o keymap.o mailbox.o main.o menu.o muttlib.o \ mutt_account.o mutt_attach.o mutt_body.o mutt_header.o \ mutt_history.o mutt_logging.o mutt_parse.o mutt_signal.o \ @@ -249,7 +249,7 @@ ALLOBJS+= $(LIBEMAILOBJS) # libmutt LIBMUTT= libmutt.a LIBMUTTOBJS= mutt/base64.o mutt/buffer.o mutt/charset.o mutt/date.o \ - mutt/envlist.o mutt/exit.o mutt/file.o mutt/hash.o \ + mutt/envlist.o mutt/exit.o mutt/file.o mutt/group.o mutt/hash.o \ mutt/history.o mutt/list.o mutt/logging.o mutt/mapping.o \ mutt/mbyte.o mutt/md5.o mutt/memory.o mutt/path.o mutt/regex.o \ mutt/sha1.o mutt/signal.o mutt/string.o diff --git a/email/address.c b/email/address.c index deed9e051..f88e442c5 100644 --- a/email/address.c +++ b/email/address.c @@ -1314,6 +1314,51 @@ struct Address *mutt_addrlist_dedupe(struct Address *addr) addr = addr->next; } } + return top; +} + +/** + * mutt_addr_remove_xrefs - Remove cross-references + * @param a Reference list of Addresses + * @param b Address list to trim + * @retval ptr Updated Address list + * + * Remove addresses from "b" which are contained in "a" + */ +struct Address *mutt_addr_remove_xrefs(struct Address *a, struct Address *b) +{ + struct Address *p = NULL, *prev = NULL; + struct Address *top = b; + while (b) + { + for (p = a; p; p = p->next) + { + if (mutt_addr_cmp(p, b)) + break; + } + if (p) + { + if (prev) + { + prev->next = b->next; + b->next = NULL; + mutt_addr_free(&b); + b = prev; + } + else + { + top = top->next; + b->next = NULL; + mutt_addr_free(&b); + b = top; + } + } + else + { + prev = b; + b = b->next; + } + } return top; } diff --git a/email/address.h b/email/address.h index 499187691..55c46d397 100644 --- a/email/address.h +++ b/email/address.h @@ -74,6 +74,7 @@ struct Address *mutt_addr_new(void); struct Address *mutt_addr_parse_list(struct Address *top, const char *s); struct Address *mutt_addr_parse_list2(struct Address *p, const char *s); void mutt_addr_qualify(struct Address *addr, const char *host); +struct Address *mutt_addr_remove_xrefs(struct Address *a, struct Address *b); int mutt_addr_remove_from_list(struct Address **a, const char *mailbox); bool mutt_addr_search(struct Address *a, struct Address *lst); void mutt_addr_set_intl(struct Address *a, char *intl_mailbox); diff --git a/globals.h b/globals.h index 09a161e51..d98e4b42c 100644 --- a/globals.h +++ b/globals.h @@ -54,7 +54,6 @@ WHERE char *LastFolder; ///< Previously selected mailbox extern const char *GitVer; -WHERE struct Hash *Groups; ///< Hash table of alias groups (name -> Group) WHERE struct Hash *ReverseAliases; ///< Hash table of aliases (email address -> alias) WHERE struct Hash *TagFormats; ///< Hash table of tag-formats (tag -> format string) diff --git a/init.c b/init.c index 9dea765cd..20fdc8d26 100644 --- a/init.c +++ b/init.c @@ -48,7 +48,6 @@ #include "alias.h" #include "context.h" #include "filter.h" -#include "group.h" #include "hcache/hcache.h" #include "keymap.h" #include "menu.h" diff --git a/init.h b/init.h index 4f24f950d..9cd4f4640 100644 --- a/init.h +++ b/init.h @@ -43,7 +43,6 @@ #include "curs_lib.h" #include "edit.h" #include "globals.h" -#include "group.h" #include "handler.h" #include "hdrline.h" #include "hook.h" diff --git a/group.c b/mutt/group.c similarity index 97% rename from group.c rename to mutt/group.c index 8b8ed4c6d..6b8a690f0 100644 --- a/group.c +++ b/mutt/group.c @@ -33,8 +33,13 @@ #include "mutt/mutt.h" #include "email/lib.h" #include "group.h" -#include "globals.h" -#include "send.h" +#include "hash.h" +#include "logging.h" +#include "memory.h" +#include "regex3.h" +#include "string2.h" + +struct Hash *Groups; /** * mutt_pattern_group - Match a pattern to a Group @@ -160,7 +165,7 @@ static void group_add_addrlist(struct Group *g, struct Address *a) ; q = mutt_addr_copy_list(a, false); - q = mutt_remove_xrefs(g->as, q); + q = mutt_addr_remove_xrefs(g->as, q); *p = q; } diff --git a/group.h b/mutt/group.h similarity index 96% rename from group.h rename to mutt/group.h index a36854e6f..d742e5290 100644 --- a/group.h +++ b/mutt/group.h @@ -25,9 +25,14 @@ #define MUTT_GROUP_H #include +#include "queue.h" +#include "regex3.h" struct Address; struct Buffer; +struct Hash; + +extern struct Hash *Groups; #define MUTT_GROUP 0 #define MUTT_UNGROUP 1 diff --git a/mutt/hash.h b/mutt/hash.h index 74ee2e589..68e368295 100644 --- a/mutt/hash.h +++ b/mutt/hash.h @@ -26,7 +26,7 @@ #include #include -#include +#include /** * union HashKey - The data item stored in a HashElem diff --git a/mutt/mutt.h b/mutt/mutt.h index ffc53041f..a25207cc2 100644 --- a/mutt/mutt.h +++ b/mutt/mutt.h @@ -34,6 +34,7 @@ * | mutt/envlist.c | @subpage envlist | * | mutt/exit.c | @subpage exit | * | mutt/file.c | @subpage file | + * | mutt/group.c | @subpage group | * | mutt/hash.c | @subpage hash | * | mutt/history.c | @subpage history | * | mutt/list.c | @subpage list | @@ -62,6 +63,7 @@ #include "envlist.h" #include "exit.h" #include "file.h" +#include "group.h" #include "hash.h" #include "history.h" #include "list.h" diff --git a/pattern.c b/pattern.c index 9d4af76f4..568c00184 100644 --- a/pattern.c +++ b/pattern.c @@ -49,7 +49,6 @@ #include "curs_lib.h" #include "filter.h" #include "globals.h" -#include "group.h" #include "handler.h" #include "hdrline.h" #include "mailbox.h" diff --git a/send.c b/send.c index c3cf180f9..1232b55c3 100644 --- a/send.c +++ b/send.c @@ -146,52 +146,6 @@ static void append_signature(FILE *f) } } -/** - * mutt_remove_xrefs - Remove cross-references - * @param a Reference list of Addresses - * @param b Address list to trim - * @retval ptr Updated Address list - * - * Remove addresses from "b" which are contained in "a" - */ -struct Address *mutt_remove_xrefs(struct Address *a, struct Address *b) -{ - struct Address *p = NULL, *prev = NULL; - - struct Address *top = b; - while (b) - { - for (p = a; p; p = p->next) - { - if (mutt_addr_cmp(p, b)) - break; - } - if (p) - { - if (prev) - { - prev->next = b->next; - b->next = NULL; - mutt_addr_free(&b); - b = prev; - } - else - { - top = top->next; - b->next = NULL; - mutt_addr_free(&b); - b = top; - } - } - else - { - prev = b; - b = b->next; - } - } - return top; -} - /** * remove_user - Remove any address which matches the current user * @param a List of addresses @@ -836,7 +790,7 @@ void mutt_fix_reply_recipients(struct Envelope *env) /* the CC field can get cluttered, especially with lists */ env->to = mutt_addrlist_dedupe(env->to); env->cc = mutt_addrlist_dedupe(env->cc); - env->cc = mutt_remove_xrefs(env->to, env->cc); + env->cc = mutt_addr_remove_xrefs(env->to, env->cc); if (env->cc && !env->to) {