diff options
author | Søren Sandmann Pedersen <ssp@l3000.localdomain> | 2010-12-06 03:41:08 -0500 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@l3000.localdomain> | 2010-12-20 10:48:51 -0500 |
commit | 8766c7268a4bba4d35d16a4ce94938e187052b68 (patch) | |
tree | d88a54a1fc914a79ac8ffe85f217896b803ce622 | |
parent | 34ee35d482c0678d6a5fd505f94a4d8dc26e8d76 (diff) |
Refactor loop to get rid of goto
-rw-r--r-- | dda.c | 23 |
1 files changed, 10 insertions, 13 deletions
@@ -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); } } |