mu: Extract function for comparing two containers
This commit is contained in:
@ -317,6 +317,18 @@ struct _SortFuncData {
|
|||||||
};
|
};
|
||||||
typedef struct _SortFuncData SortFuncData;
|
typedef struct _SortFuncData SortFuncData;
|
||||||
|
|
||||||
|
static int
|
||||||
|
container_cmp (MuContainer *a, MuContainer *b, MuMsgFieldId mfid)
|
||||||
|
{
|
||||||
|
if (a == b)
|
||||||
|
return 0;
|
||||||
|
else if (!a->msg)
|
||||||
|
return 1;
|
||||||
|
else if (!b->msg)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return mu_msg_cmp (a->msg, b->msg, mfid);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sort_func_wrapper (MuContainer *a, MuContainer *b, SortFuncData *data)
|
sort_func_wrapper (MuContainer *a, MuContainer *b, SortFuncData *data)
|
||||||
@ -328,17 +340,10 @@ sort_func_wrapper (MuContainer *a, MuContainer *b, SortFuncData *data)
|
|||||||
for (a1 = a; a1->msg == NULL && a1->child != NULL; a1 = a1->child);
|
for (a1 = a; a1->msg == NULL && a1->child != NULL; a1 = a1->child);
|
||||||
for (b1 = b; b1->msg == NULL && b1->child != NULL; b1 = b1->child);
|
for (b1 = b; b1->msg == NULL && b1->child != NULL; b1 = b1->child);
|
||||||
|
|
||||||
if (a1 == b1)
|
|
||||||
return 0;
|
|
||||||
else if (!a1->msg)
|
|
||||||
return 1;
|
|
||||||
else if (!b1->msg)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (data->descending)
|
if (data->descending)
|
||||||
return mu_msg_cmp (b1->msg, a1->msg, data->mfid);
|
return container_cmp (b1, a1, data->mfid);
|
||||||
else
|
else
|
||||||
return mu_msg_cmp (a1->msg, b1->msg, data->mfid);
|
return container_cmp (a1, b1, data->mfid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static MuContainer*
|
static MuContainer*
|
||||||
|
|||||||
Reference in New Issue
Block a user