From 4b3b3d792ded303af0ac4a70479eca8140bc0fd2 Mon Sep 17 00:00:00 2001 From: Etienne Brateau <etienne.brateau@gmail.com> Date: Fri, 1 Nov 2019 17:25:27 +0100 Subject: [PATCH] Reindent some files --- src/attrs.c | 3 ++- src/gate.c | 28 +++++++++++++++++++++++----- src/node.c | 12 +++++++++++- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/attrs.c b/src/attrs.c index ebcd76d..30011a0 100644 --- a/src/attrs.c +++ b/src/attrs.c @@ -1,6 +1,7 @@ #include "attrs.h" -#include "settings.h" +#include <string.h> #include <utils/strings.h> +#include "settings.h" void newattrs(log_gattrrec **gattr, short numattrs, log_kattrrec *kattr) { diff --git a/src/gate.c b/src/gate.c index 940afb5..d06e7d4 100644 --- a/src/gate.c +++ b/src/gate.c @@ -271,8 +271,11 @@ void closergate(short x, short y) log_page *current_page = get_current_page(); if (gg.textinvisible) + { gg.nearlabel = NULL; - else { + } + else + { gg.nearlabel = current_page->lbase; while (gg.nearlabel != NULL && (x < gg.nearlabel->x || @@ -282,12 +285,16 @@ void closergate(short x, short y) gg.nearlabel = gg.nearlabel->next; } } - if (gg.nearlabel != NULL) { + + if (gg.nearlabel != NULL) + { gg.nearbox = NULL; gg.neargate = NULL; return; } - if (!gg.textinvisible) { + + if (!gg.textinvisible) + { gg.nearbox = current_page->bbase; while (gg.nearbox != NULL && ((x != gg.nearbox->x1 && x != gg.nearbox->x2 && @@ -295,13 +302,18 @@ void closergate(short x, short y) y != gg.nearbox->y2) || x < gg.nearbox->x1 || x > gg.nearbox->x2 || y < gg.nearbox->y1 || y > gg.nearbox->y2)) gg.nearbox = gg.nearbox->next; - } else + } + else + { gg.nearbox = NULL; + } + if (gg.nearbox != NULL) { gg.neargate = NULL; return; } + gg.neargate = current_page->gbase; while (gg.neargate != NULL && !insidegate(gg.neargate, x, y)) gg.neargate = gg.neargate->next; @@ -463,7 +475,8 @@ void disconnectgate(log_grec *gate) if (!P_inset(i, done)) { j = i; - do { + do + { chggatepin(gate, j, &oldnode[i - 1]); P_addset(done, j); j = gate->kind->pin[j - 1].c; @@ -601,11 +614,14 @@ int connectgate(log_grec *gate) } g1 = g1->next; } + if (n1 != NULL) queuecombine(&cnbase, &gate->pin[ptrs[i] - 1], n1); } + if (gate->kind->simtype == simtype_common && gate->sig != 0) queuecombine(&cnbase, &gg.signaltab[gate->sig - 1].np, gate->pin); + gg.actflag = true; calltoolgate(gate, act_connectgate); success = gg.actflag; @@ -682,11 +698,13 @@ void addgate2(short x, short y, short gtype, short sig, log_gattrrec *attrs) clipon(); drawgatex(g); clipoff(); + if (!connectgate(g)) { frygate(g); disposegate(&g); } + gg.refrflag = true; gg.neargate = g; } diff --git a/src/node.c b/src/node.c index 8992fe0..c677b79 100644 --- a/src/node.c +++ b/src/node.c @@ -75,6 +75,7 @@ void disposenode(log_nrec **node) trace_message("Dispose node %p\n", *node); if (*node == NULL) return; + if ((*node)->conflict || (*node)->oconflict) { n1 = nodeconflictbase; @@ -91,8 +92,10 @@ void disposenode(log_nrec **node) else n2->confnext = (*node)->confnext; } + if (*node == gg.probenode) gg.probenode = NULL; + stamp(&(*node)->simtype->netstamp); calltoolnode(*node, act_disposenode); n1 = gg.nbase; @@ -104,6 +107,7 @@ void disposenode(log_nrec **node) { while (n1 != NULL && n1->next != *node) n1 = n1->next; + if (n1 == NULL) report(10, rtn); else @@ -151,13 +155,19 @@ void unrefnode(log_nrec **node) { if (*node == NULL) return; + (*node)->ref--; trace_message("Unref node %p -> %d\n", *node, (*node)->ref); + if ((*node)->ref > 0) return; + if ((*node)->ref < 0) + { report(10, rtn); - else { + } + else + { if (!(*node)->keep) disposenode(node); } -- GitLab