Index: work/polydev/Makefile =================================================================== --- work/polydev/Makefile (revision 8204) +++ work/polydev/Makefile (revision 8205) @@ -13,3 +13,5 @@ LDLIBS=-lm test: test.o $(PCB_RND_OBJS) + +test.o: test.c polygon_fix.c Index: work/polydev/p.rect =================================================================== --- work/polydev/p.rect (revision 8204) +++ work/polydev/p.rect (revision 8205) @@ -1,4 +1,4 @@ polygon A 0 0 10 0 10 15 0 15 draw A check A - +cleanup A B Index: work/polydev/polygon_fix.c =================================================================== --- work/polydev/polygon_fix.c (nonexistent) +++ work/polydev/polygon_fix.c (revision 8205) @@ -0,0 +1,15 @@ +/* This file will be copied into the polygon lib */ + +int pcb_polygon_cleanup(pcb_polyarea_t *input, pcb_polyarea_t **output, int out_max) +{ + if (out_max < 1) + return -1; + + /* if input is already fine, just return it */ + if (pcb_poly_valid(input)) { + output[0] = input; + return 1; + } + + return -1; +} Index: work/polydev/test.c =================================================================== --- work/polydev/test.c (revision 8204) +++ work/polydev/test.c (revision 8205) @@ -223,10 +223,11 @@ } +#include "polygon_fix.c" /*****************/ -#define get_idx() \ - int idx = toupper(arg[0]); \ +#define get_idx_(idx) \ + idx = toupper(arg[0]); \ if (!isspace(arg[1])) { \ fprintf(stderr, "ERROR: invalid polygon index: not a single character\n"); \ continue; \ @@ -238,6 +239,8 @@ idx -= 'A'; \ arg += 2; +#define get_idx() int idx = get_idx_(idx) + int main(int argc, char *argv[]) { char line[8192], *cmd, *arg; @@ -267,6 +270,12 @@ get_idx(); printf("%s\n", poly_valid(pa[idx]) ? "!check: valid" : "!check: INVALID"); } + else if (strcmp(cmd, "cleanup") == 0) { + int input_idx, output_idx; + get_idx_(input_idx); + get_idx_(output_idx); + printf("!cleanup: %d\n", pcb_polygon_cleanup(pa[input_idx], &pa[output_idx], ('Z' - 'A') - output_idx)); + } else fprintf(stderr, "syntax error\n"); }