The function generating a list of parts to join had incorrect sorting
logic. It was comparing values, not attributes. Additionally, the
order logic wasn't correct.
Thanks to TAKAHASHI Tamotsu for pointing out the value vs attribute
comparison bug.
struct rfc2231_parameter *par)
{
struct rfc2231_parameter **last = list;
- struct rfc2231_parameter *p = *list, *q;
+ struct rfc2231_parameter *p = *list;
int c;
-
+
while (p)
{
- last = &p->next;
- q = p; p = p->next;
-
- c = strcmp (par->value, q->value);
- if ((c > 0) || (c == 0 && par->index >= q->index))
+ c = strcmp (par->attribute, p->attribute);
+ if ((c < 0) || (c == 0 && par->index <= p->index))
break;
+
+ last = &p->next;
+ p = p->next;
}
-
+
par->next = p;
*last = par;
}