Index: work/polydev/p.rect =================================================================== --- work/polydev/p.rect (revision 8183) +++ work/polydev/p.rect (revision 8184) @@ -1,4 +1,4 @@ -polygon 0 0 10 0 10 15 0 15 -draw -check +polygon A 0 0 10 0 10 15 0 15 +draw A +check A Index: work/polydev/p.rect.hole =================================================================== --- work/polydev/p.rect.hole (revision 8183) +++ work/polydev/p.rect.hole (revision 8184) @@ -1,4 +1,4 @@ -polygon -1 -1 10 0 10 15 0 15 h 3 3 5 3 5 5 -draw -check +polygon A -1 -1 10 0 10 15 0 15 h 3 3 5 3 5 5 +draw A +check A Index: work/polydev/p.si.rect =================================================================== --- work/polydev/p.si.rect (revision 8183) +++ work/polydev/p.si.rect (revision 8184) @@ -1,4 +1,4 @@ -polygon 0 0 10 0 10 15 5 -4 -draw -check +polygon A 0 0 10 0 10 15 5 -4 +draw A +check A Index: work/polydev/test.c =================================================================== --- work/polydev/test.c (revision 8183) +++ work/polydev/test.c (revision 8184) @@ -9,6 +9,9 @@ #include "polyarea.h" #include "polygon.h" +pcb_polyarea_t *pa['Z'-'A']; + + extern void pcb_poly_insert_holes(jmp_buf * e1, pcb_polyarea_t * dest, pcb_pline_t ** src); pcb_polyarea_t *pcb_poly_from_contour(pcb_pline_t * contour) @@ -190,13 +193,23 @@ +/*****************/ +#define get_idx() \ + int idx = toupper(arg[0]); \ + if (!isspace(arg[1])) { \ + fprintf(stderr, "ERROR: invalid polygon index: not a single character\n"); \ + continue; \ + } \ + if ((idx < 'A') || (idx > 'Z')) { \ + fprintf(stderr, "ERROR: invalid polygon index %c: out of range\n", idx); \ + continue; \ + } \ + idx -= 'A'; \ + arg += 2; - -/*****************/ int main(int argc, char *argv[]) { char line[8192], *cmd, *arg; - pcb_polyarea_t *pa = NULL; while(fgets(line, sizeof(line), stdin) != NULL) { @@ -211,16 +224,21 @@ while(isspace(*arg)) arg++; } if (strcmp(cmd, "polygon") == 0) { - pa = ply_parse(arg); - if (pa == NULL) + get_idx(); + pa[idx] = ply_parse(arg); + if (pa[idx] == NULL) fprintf(stderr, "poly parse error\n"); } - else if (strcmp(cmd, "draw") == 0) - draw(pa); + else if (strcmp(cmd, "draw") == 0) { + get_idx(); + draw(pa[idx]); + } else if (strcmp(cmd, "echo") == 0) printf(arg); - else if (strcmp(cmd, "check") == 0) - printf("%s\n", poly_valid(pa) ? "!check: valid" : "!check: INVALID"); + else if (strcmp(cmd, "check") == 0) { + get_idx(); + printf("%s\n", poly_valid(pa[idx]) ? "!check: valid" : "!check: INVALID"); + } else fprintf(stderr, "syntax error\n"); }