Index: 1.1.4/src/netlist_act.c =================================================================== --- 1.1.4/src/netlist_act.c (revision 5758) +++ 1.1.4/src/netlist_act.c (revision 5759) @@ -114,30 +114,51 @@ /* The primary purpose of this action is to rebuild a netlist from a script, in conjunction with the clear action above. */ -static int pcb_netlist_add(const char *netname, const char *pinname) +static int pcb_netlist_add(int patch, const char *netname, const char *pinname) { int ni, pi; - LibraryType *netlist = &PCB->NetlistLib[NETLIST_EDITED]; + LibraryType *netlist = patch ? &PCB->NetlistLib[NETLIST_EDITED] : &PCB->NetlistLib[NETLIST_INPUT]; LibraryMenuType *net = NULL; LibraryEntryType *pin = NULL; - for (ni = 0; ni < netlist->MenuN; ni++) + for (ni = 0; ni < netlist->MenuN; ni++) { if (strcmp(netlist->Menu[ni].Name + 2, netname) == 0) { net = &(netlist->Menu[ni]); break; } + } + + if (net == NULL) { - net = CreateNewNet(netlist, (char *) netname, NULL); + if (!patch) { + net = CreateNewNet(netlist, (char *) netname, NULL); + net->Name = pcb_strdup_printf(" %s", netname); + net->flag = 1; + PCB->netlist_needs_update=1; + } + else { + abort(); /* applying this to net patch is not supported until 1.2.0 */ + } } - for (pi = 0; pi < net->EntryN; pi++) + for (pi = 0; pi < net->EntryN; pi++) { if (strcmp(net->Entry[pi].ListEntry, pinname) == 0) { pin = &(net->Entry[pi]); break; } + } + + if (pin == NULL) { - pin = CreateNewConnection(net, (char *) pinname); - rats_patch_append_optimize(PCB, RATP_ADD_CONN, pin->ListEntry, net->Name + 2, NULL); + if (!patch) { + LibraryEntryType *entry = GetLibraryEntryMemory(net); + entry->ListEntry = pcb_strdup_printf("%s", pinname); + entry->ListEntry_dontfree = 0; + PCB->netlist_needs_update=1; + } + else { + abort(); /* applying this to net patch is not supported until 1.2.0 */ + } } pcb_netlist_changed(0); @@ -244,10 +265,11 @@ return pcb_netlist_swap(); else if (strcasecmp(argv[0], "add") == 0) { /* Add is different, because the net/pin won't already exist. */ - return pcb_netlist_add(ACTION_ARG(1), ACTION_ARG(2)); + return pcb_netlist_add(0, ACTION_ARG(1), ACTION_ARG(2)); } else if (strcasecmp(argv[0], "sort") == 0) { pcb_sort_netlist(); + rats_patch_make_edited(PCB); return 0; } else if (strcasecmp(argv[0], "freeze") == 0) { @@ -275,8 +297,8 @@ if (argc > 1) { use_re = 1; - for (i = 0; i < PCB->NetlistLib[NETLIST_EDITED].MenuN; i++) { - net = PCB->NetlistLib[NETLIST_EDITED].Menu + i; + for (i = 0; i < PCB->NetlistLib[NETLIST_INPUT].MenuN; i++) { + net = PCB->NetlistLib[NETLIST_INPUT].Menu + i; if (strcasecmp(argv[1], net->Name + 2) == 0) use_re = 0; } @@ -290,9 +312,10 @@ } } - for (i = PCB->NetlistLib[NETLIST_EDITED].MenuN - 1; i >= 0; i--) { - net = PCB->NetlistLib[NETLIST_EDITED].Menu + i; +/* This code is for changing the netlist style */ + for (i = PCB->NetlistLib[NETLIST_INPUT].MenuN - 1; i >= 0; i--) { + net = PCB->NetlistLib[NETLIST_INPUT].Menu + i; if (argc > 1) { if (use_re) { if (re_sei_exec(regex, net->Name + 2) == 0)