From: Richard Russon Date: Wed, 29 Nov 2017 01:13:11 +0000 (+0000) Subject: move statics first X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=84d6335f9ef7734388f60a2097be1ae71284aa94;p=neomutt move statics first --- diff --git a/address.c b/address.c index 07421c672..1acb7c519 100644 --- a/address.c +++ b/address.c @@ -68,36 +68,6 @@ const char AddressSpecials[] = "@.,:;<>[]\\\"()"; */ #define is_special(x) strchr(AddressSpecials, x) -/** - * AddressError - An out-of-band error code - * - * Many of the Address functions set this variable on error. - * Its values are defined in #AddressError. - * Text for the errors can be looked up using #AddressErrors. - */ -int AddressError = 0; - -/** - * AddressErrors - Messages for the error codes in #AddressError - * - * These must defined in the same order as enum AddressError. - */ -const char *const AddressErrors[] = { - "out of memory", "mismatched parenthesis", "mismatched quotes", - "bad route in <>", "bad address in <>", "bad address spec", -}; - -/** - * mutt_addr_new - Create a new Address - * @retval ptr Newly allocated Address - * - * Free the result with free_address() or mutt_addr_free() - */ -struct Address *mutt_addr_new(void) -{ - return mutt_mem_calloc(1, sizeof(struct Address)); -} - /** * free_address - Free a single Address * @param a Address to free @@ -113,59 +83,6 @@ static void free_address(struct Address **a) FREE(&(*a)); } -/** - * mutt_addr_remove_from_list - Remove an Address from a list - * @param a Address list - * @param mailbox Email address to match - * @retval 0 Success - * @retval -1 Error, or email not found - */ -int mutt_addr_remove_from_list(struct Address **a, const char *mailbox) -{ - struct Address *p = NULL, *last = NULL, *t = NULL; - int rc = -1; - - p = *a; - last = NULL; - while (p) - { - if (mutt_str_strcasecmp(mailbox, p->mailbox) == 0) - { - if (last) - last->next = p->next; - else - (*a) = p->next; - t = p; - p = p->next; - free_address(&t); - rc = 0; - } - else - { - last = p; - p = p->next; - } - } - - return rc; -} - -/** - * mutt_addr_free - Free a list of Addresses - * @param p Top of the list - */ -void mutt_addr_free(struct Address **p) -{ - struct Address *t = NULL; - - while (*p) - { - t = *p; - *p = (*p)->next; - free_address(&t); - } -} - /** * parse_comment - Extract a comment (parenthesised string) * @param[in] s String, just after the opening parenthesis @@ -478,6 +395,89 @@ static void add_addrspec(struct Address **top, struct Address **last, const char *last = cur; } +/** + * AddressError - An out-of-band error code + * + * Many of the Address functions set this variable on error. + * Its values are defined in #AddressError. + * Text for the errors can be looked up using #AddressErrors. + */ +int AddressError = 0; + +/** + * AddressErrors - Messages for the error codes in #AddressError + * + * These must defined in the same order as enum AddressError. + */ +const char *const AddressErrors[] = { + "out of memory", "mismatched parenthesis", "mismatched quotes", + "bad route in <>", "bad address in <>", "bad address spec", +}; + +/** + * mutt_addr_new - Create a new Address + * @retval ptr Newly allocated Address + * + * Free the result with free_address() or mutt_addr_free() + */ +struct Address *mutt_addr_new(void) +{ + return mutt_mem_calloc(1, sizeof(struct Address)); +} + +/** + * mutt_addr_remove_from_list - Remove an Address from a list + * @param a Address list + * @param mailbox Email address to match + * @retval 0 Success + * @retval -1 Error, or email not found + */ +int mutt_addr_remove_from_list(struct Address **a, const char *mailbox) +{ + struct Address *p = NULL, *last = NULL, *t = NULL; + int rc = -1; + + p = *a; + last = NULL; + while (p) + { + if (mutt_str_strcasecmp(mailbox, p->mailbox) == 0) + { + if (last) + last->next = p->next; + else + (*a) = p->next; + t = p; + p = p->next; + free_address(&t); + rc = 0; + } + else + { + last = p; + p = p->next; + } + } + + return rc; +} + +/** + * mutt_addr_free - Free a list of Addresses + * @param p Top of the list + */ +void mutt_addr_free(struct Address **p) +{ + struct Address *t = NULL; + + while (*p) + { + t = *p; + *p = (*p)->next; + free_address(&t); + } +} + /** * mutt_addr_parse_list - Parse a list of email addresses * @param top List to append addresses diff --git a/tags.c b/tags.c index 491d5693b..8a62e78e1 100644 --- a/tags.c +++ b/tags.c @@ -53,29 +53,6 @@ char *HiddenTags; /**< Private tags which should not be displayed */ struct Hash *TagTransforms; /**< Lookup table of alternative tag names */ -/** - * driver_tags_free - Free tags from a header - * @param[in] head List of tags - * - * Free the whole tags structure - */ -void driver_tags_free(struct TagHead *head) -{ - if (!head) - return; - - struct TagNode *np = STAILQ_FIRST(head), *next = NULL; - while (np) - { - next = STAILQ_NEXT(np, entries); - FREE(&np->name); - FREE(&np->transformed); - FREE(&np); - np = next; - } - STAILQ_INIT(head); -} - /** * driver_tags_getter - Get transformed tags * @param head List of tags @@ -109,6 +86,62 @@ static char *driver_tags_getter(struct TagHead *head, bool show_hidden, return tags; } +/** + * driver_tags_add - Add a tag to header + * @param[in] head List of tags + * @param[in] new_tag string representing the new tag + * + * Add a tag to the header tags + */ +static void driver_tags_add(struct TagHead *head, char *new_tag) +{ + char *new_tag_transformed = mutt_hash_find(TagTransforms, new_tag); + + struct TagNode *np = mutt_mem_calloc(1, sizeof(struct TagNode)); + np->name = mutt_str_strdup(new_tag); + np->hidden = false; + if (new_tag_transformed) + np->transformed = mutt_str_strdup(new_tag_transformed); + + /* filter out hidden tags */ + if (HiddenTags) + { + char *p = strstr(HiddenTags, new_tag); + size_t xsz = p ? mutt_str_strlen(new_tag) : 0; + + if (p && ((p == HiddenTags) || (*(p - 1) == ',') || (*(p - 1) == ' ')) && + ((*(p + xsz) == '\0') || (*(p + xsz) == ',') || (*(p + xsz) == ' '))) + { + np->hidden = true; + } + } + + STAILQ_INSERT_TAIL(head, np, entries); +} + +/** + * driver_tags_free - Free tags from a header + * @param[in] head List of tags + * + * Free the whole tags structure + */ +void driver_tags_free(struct TagHead *head) +{ + if (!head) + return; + + struct TagNode *np = STAILQ_FIRST(head), *next = NULL; + while (np) + { + next = STAILQ_NEXT(np, entries); + FREE(&np->name); + FREE(&np->transformed); + FREE(&np); + np = next; + } + STAILQ_INIT(head); +} + /** * driver_tags_get_transformed - Get transformed tags * @param[in] head List of tags @@ -159,39 +192,6 @@ char *driver_tags_get_transformed_for(char *name, struct TagHead *head) return driver_tags_getter(head, true, true, name); } -/** - * driver_tags_add - Add a tag to header - * @param[in] head List of tags - * @param[in] new_tag string representing the new tag - * - * Add a tag to the header tags - */ -static void driver_tags_add(struct TagHead *head, char *new_tag) -{ - char *new_tag_transformed = mutt_hash_find(TagTransforms, new_tag); - - struct TagNode *np = mutt_mem_calloc(1, sizeof(struct TagNode)); - np->name = mutt_str_strdup(new_tag); - np->hidden = false; - if (new_tag_transformed) - np->transformed = mutt_str_strdup(new_tag_transformed); - - /* filter out hidden tags */ - if (HiddenTags) - { - char *p = strstr(HiddenTags, new_tag); - size_t xsz = p ? mutt_str_strlen(new_tag) : 0; - - if (p && ((p == HiddenTags) || (*(p - 1) == ',') || (*(p - 1) == ' ')) && - ((*(p + xsz) == '\0') || (*(p + xsz) == ',') || (*(p + xsz) == ' '))) - { - np->hidden = true; - } - } - - STAILQ_INSERT_TAIL(head, np, entries); -} - /** * driver_tags_replace - Replace all tags * @param[in] head List of tags