diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2005-08-10 08:15:22 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2005-08-10 08:15:22 +0000 |
commit | e16c94f2ccdc6c01b637862aeb40c3c71d36dbb5 (patch) | |
tree | 1e561ab0ad287c7a12da9f2b03985a05d3e72a90 | |
parent | b8650926df468289f0a63b90904f3674e3b1f0dc (diff) | |
download | mailutils-e16c94f2ccdc6c01b637862aeb40c3c71d36dbb5.tar.gz mailutils-e16c94f2ccdc6c01b637862aeb40c3c71d36dbb5.tar.bz2 |
(util_msgset): For message sets in form X:Y where
Y is a not-existing UID greater than maximum UID value in the
mailbox, replace Y with the latter.
-rw-r--r-- | imap4d/util.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/imap4d/util.c b/imap4d/util.c index d9292e16b..e3e5845a9 100644 --- a/imap4d/util.c +++ b/imap4d/util.c @@ -168,7 +168,9 @@ util_msgset (char *s, size_t ** set, int *n, int isuid) size_t max = 0; size_t *tmp; int i, j; - + unsigned long invalid_uid = 0; /* For UID mode only: have we + encountered an uid > max uid? */ + status = mailbox_messages_count (mbox, &max); if (status != 0) return status; @@ -200,13 +202,25 @@ util_msgset (char *s, size_t ** set, int *n, int isuid) { errno = 0; val = strtoul (s, &s, 10); - if ((val == ULONG_MAX && errno == ERANGE) || val > max) + if (val == ULONG_MAX && errno == ERANGE) { if (*set) free (*set); *n = 0; return EINVAL; } + else if (val > max) + { + if (isuid) + { + invalid_uid = 1; + continue; + } + if (*set) + free (*set); + *n = 0; + return EINVAL; + } if (low) { @@ -286,6 +300,16 @@ util_msgset (char *s, size_t ** set, int *n, int isuid) break; } /* while */ + /* For message sets in form X:Y where Y is a not-existing UID, + replace it with the last UID in the mailbox */ + if (*n == 1 && invalid_uid) + { + val = max; + status = add2set (set, n, val); + if (status != 0) + return status; + } + if (low) { /* Reverse it. */ |