svn commit: r551260 - in head/mail/mailutils: . files
Alexey Dokuchaev
danfe at FreeBSD.org
Sat Oct 3 08:07:21 UTC 2020
Author: danfe
Date: Sat Oct 3 08:07:20 2020
New Revision: 551260
URL: https://svnweb.freebsd.org/changeset/ports/551260
Log:
Backport some IMAP-related fixes from the upstream repository.
Requested by: maintainer
Added:
head/mail/mailutils/files/patch-libmailutils_base_amd.c (contents, props changed)
head/mail/mailutils/files/patch-libproto_maildir_mbox.c (contents, props changed)
Modified:
head/mail/mailutils/Makefile
Modified: head/mail/mailutils/Makefile
==============================================================================
--- head/mail/mailutils/Makefile Sat Oct 3 08:05:56 2020 (r551259)
+++ head/mail/mailutils/Makefile Sat Oct 3 08:07:20 2020 (r551260)
@@ -3,6 +3,7 @@
PORTNAME= mailutils
PORTVERSION= 3.10
+PORTREVISION= 1
CATEGORIES= mail
MASTER_SITES= GNU GNU_ALPHA
Added: head/mail/mailutils/files/patch-libmailutils_base_amd.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/mail/mailutils/files/patch-libmailutils_base_amd.c Sat Oct 3 08:07:20 2020 (r551260)
@@ -0,0 +1,47 @@
+--- libmailutils/base/amd.c.orig 2020-08-11 05:57:13 UTC
++++ libmailutils/base/amd.c
+@@ -254,18 +254,22 @@ amd_msg_bsearch (struct _amd_data *amd, mu_off_t first
+ mu_off_t mid;
+ int rc;
+
+- if (last < first)
+- return 1;
+-
+- mid = (first + last) / 2;
+- rc = amd->msg_cmp (amd->msg_array[mid], msg);
+- if (rc > 0)
+- return amd_msg_bsearch (amd, first, mid-1, msg, pret);
+- *pret = mid;
+- if (rc < 0)
+- return amd_msg_bsearch (amd, mid+1, last, msg, pret);
+- /* else */
+- return 0;
++ while (first <= last)
++ {
++ mid = (first + last) / 2;
++ rc = amd->msg_cmp (amd->msg_array[mid], msg);
++ if (rc > 0)
++ last = mid - 1;
++ else
++ {
++ *pret = mid;
++ if (rc < 0)
++ first = mid + 1;
++ else
++ return 0;
++ }
++ }
++ return 1;
+ }
+
+ /* Search for message MSG in the message array of AMD.
+@@ -318,8 +322,7 @@ amd_msg_lookup (struct _amd_data *amd, struct _amd_mes
+ }
+
+ rc = amd_msg_bsearch (amd, 0, amd->msg_count - 1, msg, &i);
+- if (rc == 0)
+- *pret = i + 1;
++ *pret = i + 1;
+ return rc;
+ }
+
Added: head/mail/mailutils/files/patch-libproto_maildir_mbox.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/mail/mailutils/files/patch-libproto_maildir_mbox.c Sat Oct 3 08:07:20 2020 (r551260)
@@ -0,0 +1,91 @@
+--- libproto/maildir/mbox.c.orig 2020-05-28 14:03:57 UTC
++++ libproto/maildir/mbox.c
+@@ -134,41 +134,67 @@ maildir_name_info_ptr (char *name)
+ return p + 3;
+ return NULL;
+ }
+-
+
++/*
++ * Compare two maildir messages A and B. The purpose is to determine
++ * which one was delivered prior to another.
++ *
++ * Compare seconds, microseconds and number of deliveries, in that
++ * order. If all match (shouldn't happen), resort to lexicographical
++ * comparison.
++ */
+ static int
+ maildir_message_cmp (struct _amd_message *a, struct _amd_message *b)
+ {
+- char *name_a, *name_b;
+- unsigned long na = strtoul (((struct _maildir_message *) a)->file_name,
+- &name_a, 10);
+- unsigned long nb = strtoul (((struct _maildir_message *) b)->file_name,
+- &name_b, 10);
+- int rc;
++ char *name_a = ((struct _maildir_message *) a)->file_name;
++ char *name_b = ((struct _maildir_message *) b)->file_name;
++ char *pa, *pb;
++ unsigned long la, lb;
++ int d;
+
+- if (na > nb)
++ la = strtoul (name_a, &name_a, 10);
++ lb = strtoul (name_b, &name_b, 10);
++
++ if (la > lb)
+ return 1;
+- if (na < nb)
++ if (la < lb)
+ return -1;
+
+- /* If timestamps are equal, compare rests of the filenames up to the
+- info marker */
++ if ((d = (*name_a - *name_b)) != 0)
++ return d;
++
++ name_a++;
++ name_b++;
+
+- if (name_a && !name_b)
+- return 1;
+- else if (!name_a)
++ if ((pa = strchr (name_a, 'M')) != 0 && (pb = strchr (name_b, 'M')) != 0)
+ {
+- if (name_b)
++ la = strtoul (name_a, &name_a, 10);
++ lb = strtoul (name_b, &name_b, 10);
++
++ if (la > lb)
++ return 1;
++ if (la < lb)
+ return -1;
+- else
+- return 0;
+ }
+-
++
++ if ((pa = strchr (name_a, 'Q')) != 0 && (pb = strchr (name_b, 'Q')) != 0)
++ {
++ la = strtoul (name_a, &name_a, 10);
++ lb = strtoul (name_b, &name_b, 10);
++
++ if (la > lb)
++ return 1;
++ if (la < lb)
++ return -1;
++ }
++
+ for (; *name_a && *name_a != ':' && *name_b && *name_b != ':';
+ name_a++, name_b++)
+- if ((rc = (*name_a - *name_b)))
+- return rc;
+-
++ {
++ if ((d = (*name_a - *name_b)) != 0)
++ return d;
++ }
++
+ if ((*name_a == ':' || *name_a == 0) && (*name_b == ':' || *name_b == 0))
+ return 0;
+
More information about the svn-ports-head
mailing list