]> granicus.if.org Git - neomutt/commitdiff
move statics first
authorRichard Russon <rich@flatcap.org>
Wed, 29 Nov 2017 01:13:11 +0000 (01:13 +0000)
committerRichard Russon <rich@flatcap.org>
Wed, 29 Nov 2017 01:13:11 +0000 (01:13 +0000)
address.c
tags.c

index 07421c6720b315ef7a3d7460e3707233b9574b4d..1acb7c519984d18b0dd209828f4184039d66bd55 100644 (file)
--- 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 491d5693bfe8652e8a5f0c308a4eaedd21192f0d..8a62e78e1889924a8769623c6c5ebb74c536bcc0 100644 (file)
--- a/tags.c
+++ b/tags.c
 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