fix pull request #492 - select_do_line of a point

Latent bug:  selection_do_line() for a single point produced
spurious line(s).

I haven't got a test case so am taking this one on faith....

While in there, do some nearby formatting fixups in sp_lev.c.

Fixes #492
This commit is contained in:
PatR
2021-04-18 14:13:57 -07:00
parent 28a77b9ab0
commit 141cafb210
+15 -13
View File
@@ -4600,9 +4600,9 @@ selection_do_gradient(
/* bresenham line algo */ /* bresenham line algo */
void void
selection_do_line( selection_do_line(
xchar x1, xchar y1, xchar x1, xchar y1,
xchar x2, xchar y2, xchar x2, xchar y2,
struct selectionvar *ov) struct selectionvar *ov)
{ {
int d0, dx, dy, ai, bi, xi, yi; int d0, dx, dy, ai, bi, xi, yi;
@@ -4613,7 +4613,6 @@ struct selectionvar *ov)
xi = -1; xi = -1;
dx = x1 - x2; dx = x1 - x2;
} }
if (y1 < y2) { if (y1 < y2) {
yi = 1; yi = 1;
dy = y2 - y1; dy = y2 - y1;
@@ -4624,7 +4623,10 @@ struct selectionvar *ov)
selection_setpoint(x1, y1, ov, 1); selection_setpoint(x1, y1, ov, 1);
if (dx > dy) { if (!dx && !dy) {
/* single point - already all done */
;
} else if (dx > dy) {
ai = (dy - dx) * 2; ai = (dy - dx) * 2;
bi = dy * 2; bi = dy * 2;
d0 = bi - dx; d0 = bi - dx;
@@ -4655,11 +4657,11 @@ struct selectionvar *ov)
void void
selection_do_randline( selection_do_randline(
xchar x1, xchar y1, xchar x1, xchar y1,
xchar x2, xchar y2, xchar x2, xchar y2,
schar rough, schar rough,
schar rec, schar rec,
struct selectionvar *ov) struct selectionvar *ov)
{ {
int mx, my; int mx, my;
int dx, dy; int dx, dy;
@@ -4698,9 +4700,9 @@ struct selectionvar *ov)
static void static void
selection_iterate( selection_iterate(
struct selectionvar *ov, struct selectionvar *ov,
select_iter_func func, select_iter_func func,
genericptr_t arg) genericptr_t arg)
{ {
int x, y; int x, y;