Branch: Tag:

2012-04-07

2012-04-07 19:48:48 by Henrik Grubbström (Grubba) <grubba@grubba.org>

array: lfun_cmp() mustn't use LFUN_EQ if LFUN_GT and LFUN_LT are lacking.

932:    default_res = CMPFUN_UNORDERED;    }    -  if ((fun = FIND_LFUN(p->inherits[SUBTYPEOF(*a)].prog, LFUN_EQ)) != -1) { +  /* NB: It's not a good idea to use LFUN_EQ here if +  * there is neither LFUN_LT nor LFUN_GT, since +  * the sorting order may get confused, which +  * will cause merge_array_with_order() to fail. +  */ +  if ((default_res == CMPFUN_UNORDERED) && +  (fun = FIND_LFUN(p->inherits[SUBTYPEOF(*a)].prog, LFUN_EQ)) != -1) {    push_svalue(b);    apply_low(a->u.object,    fun + p->inherits[SUBTYPEOF(*a)].identifier_level, 1);
971:    default_res = CMPFUN_UNORDERED;    }    -  if ((fun = FIND_LFUN(p->inherits[SUBTYPEOF(*b)].prog, LFUN_EQ)) != -1) { +  /* NB: It's not a good idea to use LFUN_EQ here if +  * there is neither LFUN_LT nor LFUN_GT, since +  * the sorting order may get confused, which +  * will cause merge_array_with_order() to fail. +  */ +  if ((default_res == CMPFUN_UNORDERED) && +  (fun = FIND_LFUN(p->inherits[SUBTYPEOF(*b)].prog, LFUN_EQ)) != -1) {    push_svalue(a);    apply_low(b->u.object,    fun + p->inherits[SUBTYPEOF(*b)].identifier_level, 1);