diff options
| author | Simon Tatham <anakin@pobox.com> | 2008-09-07 08:35:52 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2008-09-07 08:35:52 +0000 |
| commit | 4033458aff500635a10c6659e6e1c6fe0db687e9 (patch) | |
| tree | e6e481bac088fbbceb176470c88e78f011396e67 /grid.c | |
| parent | f7ab0a4996deb231165257a502a023c3024c3151 (diff) | |
| download | puzzles-4033458aff500635a10c6659e6e1c6fe0db687e9.zip puzzles-4033458aff500635a10c6659e6e1c6fe0db687e9.tar.gz puzzles-4033458aff500635a10c6659e6e1c6fe0db687e9.tar.bz2 puzzles-4033458aff500635a10c6659e6e1c6fe0db687e9.tar.xz | |
How did I manage to check this in without actually trying to build
on Windows at all?! Fix some departures from the C standard, mostly
declaring variables after a statement has already been issued in the
same block. MSVC is picky about this where gcc is forgiving, and TBH
I'd change the latter given the choice.
[originally from svn r8166]
Diffstat (limited to 'grid.c')
| -rw-r--r-- | grid.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -81,8 +81,9 @@ static double point_line_distance(int px, int py, int bx, int by) { int det = ax*by - bx*ay + bx*py - px*by + px*ay - ax*py; + double len; det = max(det, -det); - double len = sqrt(SQ(ax - bx) + SQ(ay - by)); + len = sqrt(SQ(ax - bx) + SQ(ay - by)); return det / len; } @@ -136,9 +137,10 @@ grid_edge *grid_nearest_edge(grid *g, int x, int y) int j; if (!f) continue; for (j = 0; j < f->order; j++) { + int new_dist; grid_dot *d = f->dots[j]; if (d == cur) continue; - int new_dist = SQ(d->x - x) + SQ(d->y - y); + new_dist = SQ(d->x - x) + SQ(d->y - y); if (new_dist < dist) { new = d; break; /* found closer dot */ |