Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
35ad2a8c
...
35ad2a8c5b9298170a080c87f7694614a4cbedbc
authored
2002-09-18 21:19:55 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
(mh_msgset_parse): Sort the message set and remove any duplicates from it.
1 parent
5bef1d32
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
mh/mh_msgset.c
mh/mh_msgset.c
View file @
35ad2a8
...
...
@@ -163,6 +163,16 @@ msgset_preproc (mailbox_t mbox, char *arg)
return
strdup
(
arg
);
}
static
int
comp_mesg
(
const
void
*
a
,
const
void
*
b
)
{
if
(
*
(
size_t
*
)
a
>
*
(
size_t
*
)
b
)
return
1
;
else
if
(
*
(
size_t
*
)
a
<
*
(
size_t
*
)
b
)
return
-
1
;
return
0
;
}
int
mh_msgset_parse
(
mailbox_t
mbox
,
mh_msgset_t
*
msgset
,
int
argc
,
char
**
argv
)
{
...
...
@@ -231,6 +241,15 @@ mh_msgset_parse (mailbox_t mbox, mh_msgset_t *msgset, int argc, char **argv)
free
(
arg
);
}
/* Sort the resulting message set */
qsort
(
msglist
,
msgcnt
,
sizeof
(
*
msglist
),
comp_mesg
);
/* Remove duplicates. */
for
(
i
=
0
,
msgno
=
1
;
i
<
msgcnt
;
i
++
)
if
(
msglist
[
msgno
-
1
]
!=
msglist
[
i
])
msglist
[
msgno
++
]
=
msglist
[
i
];
msgcnt
=
msgno
;
msgset
->
count
=
msgcnt
;
msgset
->
list
=
msglist
;
return
0
;
...
...
Please
register
or
sign in
to post a comment