Index: netlist.c =================================================================== --- netlist.c (revision 36746) +++ netlist.c (revision 36747) @@ -233,10 +233,25 @@ if (pn != tmp) free(pn); return t; +} +int pcb_net_is_term_on_net(pcb_net_t *net, pcb_net_term_t *term) +{ + return term->parent.net == net; } +int pcb_net_is_term_on_net_by_name(pcb_board_t *pcb, pcb_netlist_t *nl, const char *netname, const char *termname) +{ + pcb_net_t *net = pcb_net_get(pcb, nl, netname, 0); + pcb_net_term_t *term; + if (net == NULL) + return -1; + + term = pcb_net_term_get_by_pinname(net, termname, 0); + return (term != NULL); +} + int pcb_net_term_del(pcb_net_t *net, pcb_net_term_t *term) { pcb_termlist_remove(term); Index: netlist.h =================================================================== --- netlist.h (revision 36746) +++ netlist.h (revision 36747) @@ -97,6 +97,11 @@ pcb_net_t *pcb_net_get_user(pcb_board_t *pcb, pcb_netlist_t *nl, const char *name_or_rx); /* run all three above in order, until one succeeds */ +/* Check if terminal is on a specific net; returns bool 0 or 1 normally, or + -1 on error */ +int pcb_net_is_term_on_net(pcb_net_t *net, pcb_net_term_t *term); +int pcb_net_is_term_on_net_by_name(pcb_board_t *pcb, pcb_netlist_t *nl, const char *netname, const char *termname); + /* Remove a net from a netlist by namel returns 0 on removal, -1 on error */ int pcb_net_del(pcb_netlist_t *nl, const char *netname); Index: rats_patch.c =================================================================== --- rats_patch.c (revision 36746) +++ rats_patch.c (revision 36747) @@ -333,8 +333,17 @@ { switch(n->op) { case RATP_ADD_CONN: +rnd_trace("add conn: id='%s' 1='%s'\n", n->id, n->arg1.net_name); + if (pcb_net_is_term_on_net_by_name(pcb, &pcb->netlist[PCB_NETLIST_INPUT], n->arg1.net_name, n->id) == 1) { + rnd_message(RND_MSG_INFO, "rats patch: 'add connection' %s to %s is done on forward annotation, removing.\n", n->id, n->arg1.net_name); + return 1; + } break; case RATP_DEL_CONN: + if (pcb_net_is_term_on_net_by_name(pcb, &pcb->netlist[PCB_NETLIST_INPUT], n->arg1.net_name, n->id) == 0) { + rnd_message(RND_MSG_INFO, "rats patch: 'del connection' %s to %s is done on forward annotation, removing.\n", n->id, n->arg1.net_name); + return 1; + } break; case RATP_CHANGE_ATTRIB: break;