From a293ab71f3fd4c3e43741258fd95779b29b6bdea Mon Sep 17 00:00:00 2001 From: Abe Date: Sun, 9 Jun 2024 16:08:26 -0400 Subject: [PATCH] resolves #11 (#13) * increase height of preview canvas image in demo * small sized curves get cutoff (e.g. 3x3) because the window scaling factor is only 1.1 and the margins are significant at small scales. Increasing the height factor to 2 (from 1.1) alleviates the problem while minimizing the risk of the canvas spilling over horizontally. * resolves #11 * vestigial test code that caused `gilbert_d2xy(&x, &y, 7861, 490, 490)` to incorrectly return -1 (there was a `max_iter` check to return after some hard coded value) * added test to make sure at least that condition is tested for * `gilbert.c` had buffer overrun setting last byte of `buf`, correctly sets `buf[1023]='\0'` instead of `buf[1024]` --- ports/gilbert.c | 7 +------ tests/runtests.sh | 3 +++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ports/gilbert.c b/ports/gilbert.c index 10fa13f..6e300d3 100644 --- a/ports/gilbert.c +++ b/ports/gilbert.c @@ -175,8 +175,6 @@ int gilbert_d2xy_r(int dst_idx, int cur_idx, int *xres, int *yres, int ax,int ay, int bx,int by ) { - static int max_iter = 0; - int nxt_idx; int w, h, x, y, dax, day, @@ -184,9 +182,6 @@ int gilbert_d2xy_r(int dst_idx, int cur_idx, di; int ax2, ay2, bx2, by2, w2, h2; - if (max_iter > 100000) { return -1; } - max_iter++; - w = abs(ax + ay); h = abs(bx + by); @@ -891,7 +886,7 @@ int main(int argc, char **argv) { } strncpy(buf, argv[1], 1023); - buf[1024]='\0'; + buf[1023]='\0'; w = atoi(argv[2]); h = atoi(argv[3]); diff --git a/tests/runtests.sh b/tests/runtests.sh index c3001aa..5cdab09 100755 --- a/tests/runtests.sh +++ b/tests/runtests.sh @@ -159,3 +159,6 @@ gilbert_cmp2 $x $y x=7 ; y=6 ; z=4 gilbert_cmp3 $x $y $z +x=490 ; y=490 +gilbert_cmp2 $x $y +