diff options
Diffstat (limited to 'grid.c')
| -rw-r--r-- | grid.c | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -342,21 +342,23 @@ static int grid_edge_bydots_cmpfn(void *v1, void *v2) grid_edge *b = v2; grid_dot *da, *db; - /* Pointer subtraction is valid here, because all dots point into the - * same dot-list (g->dots). - * Edges are not "normalised" - the 2 dots could be stored in any order, + /* Edges are not "normalised" - the 2 dots could be stored in any order, * so we need to take this into account when comparing edges. */ /* Compare first dots */ da = (a->dot1 < a->dot2) ? a->dot1 : a->dot2; db = (b->dot1 < b->dot2) ? b->dot1 : b->dot2; - if (da != db) - return db - da; + if (da->index < db->index) + return -1; + if (da->index > db->index) + return +1; /* Compare last dots */ da = (a->dot1 < a->dot2) ? a->dot2 : a->dot1; db = (b->dot1 < b->dot2) ? b->dot2 : b->dot1; - if (da != db) - return db - da; + if (da->index < db->index) + return -1; + if (da->index > db->index) + return +1; return 0; } |