Index: src/rats.c =================================================================== --- src/rats.c (revision 57) +++ src/rats.c (revision 58) @@ -40,6 +40,7 @@ #include #include +#include #include "global.h" @@ -357,6 +358,75 @@ memset (&Netl->Net[Netl->NetN], 0, sizeof (NetType)); } +static void proc_short_cb(int type, void *obj) +{ + printf(" found %d %p\n", type, obj); +} + +static void proc_short(PinType *pin, PadType *pad) +{ + find_callback_t old_cb; + Coord x, y; + + /* only one should be set, but one must be set */ + assert((pin != NULL) || (pad != NULL)); + assert((pin == NULL) || (pad == NULL)); + + if (pin != NULL) { + printf("short on pin!\n"); + SET_FLAG (WARNFLAG, pin); + x = pin->X; + y = pin->Y; + } + else if (pad != NULL) { + printf("short on pad!\n"); + SET_FLAG (WARNFLAG, pad); + if (TEST_FLAG (EDGE2FLAG, pad)) { + x = pad->Point2.X; + y = pad->Point2.Y; + } + else { + x = pad->Point1.X; + y = pad->Point1.Y; + } + } + + old_cb = find_callback; + find_callback = proc_short_cb; + LookupConnection (x, y, false, 1, FOUNDFLAG); + find_callback = old_cb; +} + +typedef struct pinpad_s pinpad_t; +struct pinpad_s { + PinType *pin; + PadType *pad; + pinpad_t *next; +}; + +static pinpad_t *shorts = NULL; + +static void found_short(PinType *pin, PadType *pad) +{ + pinpad_t *pp; + pp = malloc(sizeof(pinpad_t)); + pp->pin = pin; + pp->pad = pad; + pp->next = shorts; + shorts = pp; +} + +static void proc_shorts(void) +{ + pinpad_t *n, *next; + for(n = shorts; n != NULL; n = next) { + next = n->next; + proc_short(n->pin, n->pad); + free(n); + } + shorts = NULL; +} + static bool CheckShorts (LibraryMenuTypePtr theNet) { @@ -381,7 +451,7 @@ &theNet->Name[2], UNKNOWN (NAMEONPCB_NAME (element)), UNKNOWN (pin->Number)); - SET_FLAG (WARNFLAG, pin); + found_short(pin, NULL); continue; } newone = true; @@ -401,7 +471,7 @@ Message (_("Warning! Net \"%s\" is shorted to net \"%s\"\n"), &theNet->Name[2], &((LibraryMenuTypePtr) (pin->Spare))->Name[2]); - SET_FLAG (WARNFLAG, pin); + found_short(pin, NULL); } } } @@ -419,7 +489,7 @@ &theNet->Name[2], UNKNOWN (NAMEONPCB_NAME (element)), UNKNOWN (pad->Number)); - SET_FLAG (WARNFLAG, pad); + found_short(NULL, pad); continue; } newone = true; @@ -439,7 +509,7 @@ Message (_("Warning! Net \"%s\" is shorted to net \"%s\"\n"), &theNet->Name[2], &((LibraryMenuTypePtr) (pad->Spare))->Name[2]); - SET_FLAG (WARNFLAG, pad); + found_short(NULL, pad); } } } @@ -793,8 +863,10 @@ if (funcp) return (true); - if (Warned || changed) + if (Warned || changed) { + proc_shorts(); Draw (); + } if (Warned) Settings.RatWarn = true;