]> git.draconx.ca Git - slotifier.git/blobdiff - src/slotifier.c
Properly return failure status from main.
[slotifier.git] / src / slotifier.c
index 01659319cf16d9506a53c730703011c60734bafd..3998926e490c15bb94eb884d602a5fba8c112ed5 100644 (file)
@@ -221,7 +221,7 @@ static int combine_holes(gerbv_image_t *drill, gerbv_net_t *hole,
        hole->aperture = -hole->aperture;
 
        for (i = 0; i < CVectorSize(group); i++) {
-               double xy[2], dia;
+               double xy[2], dia, r;
 
                CVectorGetElement(group, &hole, i);
                tool = drill->aperture[abs(hole->aperture)];
@@ -230,10 +230,13 @@ static int combine_holes(gerbv_image_t *drill, gerbv_net_t *hole,
                xy[0] = hole->start_x; xy[1] = hole->start_y;
                dia = tool->parameter[0];
 
+               /* Half a mil slop to decisively include points on boundary. */
+               r = dia/2 + 0.0005;
+
                if (drill->aperture[biggest_tool]->parameter[0] < dia)
                        biggest_tool = abs(hole->aperture);
 
-               if (CNearTreeFindInSphere(t, dia, 0, tmp, xy, 1) != 0) {
+               if (CNearTreeFindInSphere(t, r, 0, tmp, xy, 1) != 0) {
                        /* We should always should find at least one hole! */
                        fprintf(stderr, _("%s: fatal error searching holes\n"),
                                        progname);
@@ -330,6 +333,9 @@ static int slotify(gerbv_image_t *drill)
        }
 
        CNearTreeObjects(t, &holes);
+       if (!holes)
+               goto out;
+
        for (i = 0; i < CVectorSize(holes); i++) {
                gerbv_net_t *hole;
 
@@ -355,6 +361,7 @@ static int slotify(gerbv_image_t *drill)
                        gerbv_image_delete_net(hole);
        }
 
+out:
        CNearTreeFree(&t);
        return ret;
 }
@@ -432,5 +439,5 @@ int main(int argc, char **argv)
                ret = EXIT_FAILURE;
 out:
        gerbv_destroy_project(gp);
-       return 0;
+       return ret;
 }