]> granicus.if.org Git - neomutt/commitdiff
lib: move function to list.c
authorRichard Russon <rich@flatcap.org>
Tue, 7 Nov 2017 22:28:13 +0000 (22:28 +0000)
committerRichard Russon <rich@flatcap.org>
Tue, 7 Nov 2017 22:28:13 +0000 (22:28 +0000)
lib/list.c
lib/list.h
mbox.c

index b4a8e1ed968d596844a25cc77742390088831cc4..d3488aaefade9318bb48aefc4efc11881b09ae25 100644 (file)
@@ -35,6 +35,7 @@
  * | mutt_list_insert_head()  | Insert a string at the beginning of a List
  * | mutt_list_insert_tail()  | Append a string to the end of a List
  * | mutt_list_match()        | Is the string in the list (see notes)
+ * | strict_cmp_stailq()      | Compare two string lists
  */
 
 #include "config.h"
@@ -163,3 +164,32 @@ bool mutt_list_match(const char *s, struct ListHead *h)
   }
   return false;
 }
+
+/**
+ * strict_cmp_stailq - Compare two string lists
+ * @param ah First string list
+ * @param bh Second string list
+ * @retval bool True if lists are identical
+ *
+ * To be identical, the lists must both be the same length and contain the same
+ * strings.  Two empty lists are identical.
+ */
+int strict_cmp_stailq(const struct ListHead *ah, const struct ListHead *bh)
+{
+  struct ListNode *a = STAILQ_FIRST(ah);
+  struct ListNode *b = STAILQ_FIRST(bh);
+
+  while (a && b)
+  {
+    if (mutt_strcmp(a->data, b->data) != 0)
+      return 0;
+
+    a = STAILQ_NEXT(a, entries);
+    b = STAILQ_NEXT(b, entries);
+  }
+  if (a || b)
+    return 0;
+
+  return 1;
+}
+
index c566538c997f20013d29a9e42aad85f4a7ed122b..f1b4aee2b9c222e38c363a38a201217ddd460e3c 100644 (file)
@@ -52,5 +52,6 @@ struct ListNode *mutt_list_insert_after(struct ListHead *h, struct ListNode *n,
 struct ListNode *mutt_list_insert_head(struct ListHead *h, char *s);
 struct ListNode *mutt_list_insert_tail(struct ListHead *h, char *s);
 bool             mutt_list_match(const char *s, struct ListHead *h);
+int              strict_cmp_stailq(const struct ListHead *ah, const struct ListHead *bh);
 
 #endif /* _LIB_LIST_H */
diff --git a/mbox.c b/mbox.c
index d2441e740c99c9fddc984bdff9fe55b6eb5ddda2..a23b0fe413352dbcf70eaa36974b7ffb2657ab9f 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -576,31 +576,6 @@ static int strict_addrcmp(const struct Address *a, const struct Address *b)
   return 1;
 }
 
-static int strict_cmp_stailq(const struct ListHead *ah, const struct ListHead *bh)
-{
-  struct ListNode *a = STAILQ_FIRST(ah);
-  struct ListNode *b = STAILQ_FIRST(bh);
-
-  while (a && b)
-  {
-    if (mutt_strcmp(a->data, b->data) != 0)
-      return 0;
-
-    a = STAILQ_NEXT(a, entries);
-    b = STAILQ_NEXT(b, entries);
-  }
-  if (a || b)
-    return 0;
-
-  return 1;
-}
-
-/**
- * strict_cmp_envelopes - Strictly compare two Envelopes
- * @param e1 First Envelope
- * @param e2 Second Envelope
- * @retval true Envelopes are strictly identical
- */
 static int strict_cmp_envelopes(const struct Envelope *e1, const struct Envelope *e2)
 {
   if (e1 && e2)