summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@l3000.localdomain>2010-12-06 03:41:08 -0500
committerSøren Sandmann Pedersen <ssp@l3000.localdomain>2010-12-20 10:48:51 -0500
commit8766c7268a4bba4d35d16a4ce94938e187052b68 (patch)
treed88a54a1fc914a79ac8ffe85f217896b803ce622
parent34ee35d482c0678d6a5fd505f94a4d8dc26e8d76 (diff)
Refactor loop to get rid of goto
-rw-r--r--dda.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/dda.c b/dda.c
index 00fa404..354a59d 100644
--- a/dda.c
+++ b/dda.c
@@ -78,21 +78,8 @@ dda (test_data_t *testdata)
printf ("= = = = %f %f %f %f = = = = \n", x0, y0, x1, y1);
#endif
- goto step;
-
while (yi < next_sample_y (y1))
{
- if (testdata->points[i++] != xi ||
- testdata->points[i++] != yi)
- {
- printf ("error %f %f\n", testdata->points[i - 1], xi);
- exit (-1);
- }
-
- e -= sample_step_y (yi) * dx;
- yi += sample_step_y (yi);
-
- step:
if (dx >= 0)
{
while (e <= 0)
@@ -115,6 +102,16 @@ dda (test_data_t *testdata)
s = sample_step_x_backward (xi);
}
}
+
+ if (testdata->points[i++] != xi ||
+ testdata->points[i++] != yi)
+ {
+ printf ("error %f %f\n", testdata->points[i - 1], xi);
+ exit (-1);
+ }
+
+ e -= sample_step_y (yi) * dx;
+ yi += sample_step_y (yi);
}
}