38 LS_SCOPE LS_LIST_ITEM* LS_NAME(LS_COMPARE_FUNC_DECL LS_LIST_ITEM *list,
int list_len)
40 LS_LIST_ITEM *list_end;
41 LS_LIST_ITEM *sorted_list;
48 sp->list_len= list_len;
55 LS_LIST_ITEM *e1, *e2;
57 e1= LS_NEXT(sorted_list);
58 list_end= LS_NEXT(e1);
59 if (LS_COMPARE_FUNC_CALL(sorted_list, e1))
64 if (sp->list_len == 2)
66 LS_SET_NEXT(sorted_list, e1);
67 LS_SET_NEXT(e1, NULL);
71 list_end= LS_NEXT(e2);
72 if (LS_COMPARE_FUNC_CALL(e1, e2))
75 LS_LIST_ITEM *tmp_e= e1;
79 if (LS_COMPARE_FUNC_CALL(sorted_list, e1))
81 LS_LIST_ITEM *tmp_e= sorted_list;
87 LS_SET_NEXT(sorted_list, e1);
89 LS_SET_NEXT(e2, NULL);
95 sp->list_len= sp0->list_len >> 1;
96 sp0->list_len-= sp->list_len;
101 sp->list1= sorted_list;
105 sp->list_len= sp0->list_len;
108 goto recursion_point;
111 register LS_LIST_ITEM **hook= &sorted_list;
112 register LS_LIST_ITEM *list1= sp->list1;
113 register LS_LIST_ITEM *list2= sorted_list;
115 if (LS_COMPARE_FUNC_CALL(list1, list2))
117 LS_LIST_ITEM *tmp_e= list2;
126 if (!(list1= *(hook= LS_P_NEXT(list1))))
131 }
while (LS_COMPARE_FUNC_CALL(list2, list1));
136 if (!(list2= *(hook= LS_P_NEXT(list2))))
141 }
while (LS_COMPARE_FUNC_CALL(list1, list2));
146 switch ((sp--)->return_point)
148 case 0:
goto return_point0;
149 case 1:
goto return_point1;
162 #undef LS_STRUCT_NAME
164 #undef LS_COMPARE_FUNC_DECL
165 #undef LS_COMPARE_FUNC_CALL