diff --git a/log/src/log.c b/log/src/log.c index 0f6359b744d054ac6f234db371f02fccd6d94d64..15bfa2301cbf28c5b9348a03f2569547af4ec6c0 100644 --- a/log/src/log.c +++ b/log/src/log.c @@ -8581,15 +8581,8 @@ static int tryconfig(struct LOC_editattrs *LINK) } -static void editattrs(gattr_, numattrs_, kattr_, lbl_, name_, proc, chproc_, - relproc, attrstamp) - log_gattrrec *gattr_; - short numattrs_; - log_kattrrec *kattr_; - na_strlist_t *lbl_; - char *name_; - void (*proc) (), (*chproc_) (), (*relproc) (); - long *attrstamp; +static void editattrs(log_gattrrec *gattr_, short numattrs_, log_kattrrec *kattr_, na_strlist_t *lbl_, char *name_, + void (*proc) (), void (*chproc_) (), void (*relproc) (), long *attrstamp) { struct LOC_editattrs V; short i, i1, p0, olday, ytotal; @@ -8621,7 +8614,8 @@ static void editattrs(gattr_, numattrs_, kattr_, lbl_, name_, proc, chproc_, V.ybase = 0; ytotal = 0; l1 = V.lbl; - while (l1 != NULL) { + while (l1 != NULL) + { if (l1->kind == '\0') ytotal++; l1 = l1->next; @@ -8630,77 +8624,104 @@ static void editattrs(gattr_, numattrs_, kattr_, lbl_, name_, proc, chproc_, gg.actflag = true; callconfig(proc, &V); FORLIM = V.numattrs; - for (i = 0; i < FORLIM; i++) { + for (i = 0; i < FORLIM; i++) + { WITH = &V.gattr[i]; touched = false; WITH->supr = false; } maskvalues(&V); FORLIM = V.numattrs; - for (i = 1; i <= FORLIM; i++) { + for (i = 1; i <= FORLIM; i++) + { if (!V.gattr[i - 1].supr) drawvalue(i, false, &V); } showalpha(); - if (V.numattrs == 0) { - do { + if (V.numattrs == 0) + { + do + { noblink(); - do { + do + { pass(); pen(); } while (!(pollkbd2() || gg.t.dn)); + if (pollkbd2()) ch = inkey2(); else ch = '\015'; } while (ch != '\003' && ch != '\015' && ch != ' '); - } else { + } + else + { V.p = 1; olday = -1; exitflag = false; - do { + do + { noblink(); if (V.kattr[V.p - 1].y <= V.ybase || - V.kattr[V.p - 1].y >= V.ybase + txdown) { + V.kattr[V.p - 1].y >= V.ybase + txdown) + { i1 = V.ybase; - if (V.kattr[V.p - 1].y <= V.ybase) { + if (V.kattr[V.p - 1].y <= V.ybase) + { V.ybase = V.kattr[V.p - 1].y - 1; if (V.p == 1) V.ybase = P_imax2(0L, (long)(V.kattr[V.p - 1].y - txdown)); - } else { + } + else + { V.ybase = V.kattr[V.p - 1].y - txdown + 1; if (V.p == V.numattrs) V.ybase = P_imin2(ytotal - txdown - 1L, (long)V.kattr[V.p - 1].y); } + if (abs(V.ybase - i1) < txdown) nc_scrollXY(0, V.ybase - i1); else clearshowalpha(); + drawlabel(&V); FORLIM = V.numattrs; for (i = 0; i < FORLIM; i++) V.gattr[i].supr = false; + maskvalues(&V); FORLIM = V.numattrs; - for (i = 1; i <= FORLIM; i++) { + for (i = 1; i <= FORLIM; i++) + { if (!V.gattr[i - 1].supr) drawvalue(i, i == V.p, &V); } - } else + } + else + { drawvalue(V.p, true, &V); - do { + } + + do + { ch = '\0'; pass(); gg.actflag = false; callconfig(proc, &V); FORLIM = V.numattrs; - for (i = 1; i <= FORLIM; i++) { - if (V.gattr[i - 1].changed) { + for (i = 1; i <= FORLIM; i++) + { + if (V.gattr[i - 1].changed) + { stamp(attrstamp); - if (!V.gattr[i - 1].supr) { + if (!V.gattr[i - 1].supr) + { drawvalue(i, i == V.p, &V); + if (V.kattr[i - 1].dtype == 'V') maskvalues(&V); + if (V.gattr[V.p - 1].supr) ch = '\037'; noblink(); @@ -8723,57 +8744,84 @@ end; */ ch = inkey2(); } while (!(ch != '\0' || gg.t.dn)); drawvalue(V.p, false, &V); + if (gg.t.dn) ch = '\003'; p0 = V.p; understood = true; WITH = &V.gattr[V.p - 1]; + if (ch == '\003' || ch == ' ') + { exitflag = true; - else if ((ch & 255) != 251 && (ch & 255) != 250) { - if (ch == '\n') { - do { + } + else if ((ch & 255) != 251 && (ch & 255) != 250) + { + if (ch == '\n') + { + do + { V.p++; } while (V.p <= V.numattrs && V.gattr[V.p - 1].supr); + if (V.p > V.numattrs) V.p = p0; - } else if (ch == '\037') { - do { + } + else if (ch == '\037') + { + do + { V.p--; } while (V.p >= 1 && V.gattr[V.p - 1].supr); + if (V.p < 1) /*should never happen!*/ V.p = p0; - } else if (ch == '\034') { + } + else if (ch == '\034') + { gg.actflag = false; gg.actflag2 = true; callconfig(relproc, &V); - if (!gg.actflag) { - switch (V.kattr[V.p - 1].dtype) { + + if (!gg.actflag) + { + switch (V.kattr[V.p - 1].dtype) + { case 'R': case 'U': case 'F': - if (!WITH->blnk) { + if (!WITH->blnk) + { r1 = scrnincr(V.p, &V); saver = WITH->UU.r; WITH->UU.r = cleanup(WITH->UU.r + r1, r1, &V); - if (tryconfig(&V)) { + if (tryconfig(&V)) + { drawvalue(V.p, false, &V); touched = true; - } else + } + else + { WITH->UU.r = saver; + } } break; case 'I': case 'H': - if (!WITH->blnk) { + if (!WITH->blnk) + { WITH->UU.U73.i1++; - if (tryconfig(&V)) { + if (tryconfig(&V)) + { drawvalue(V.p, false, &V); touched = true; - } else + } + else + { WITH->UU.U73.i1--; + } } break; @@ -8787,11 +8835,15 @@ end; */ saveb2 = WITH->blnk; WITH->UU.b = true; WITH->blnk = false; - if (!tryconfig(&V)) { + + if (!tryconfig(&V)) + { WITH->UU.b = saveb; WITH->blnk = saveb2; } - if (WITH->UU.b != saveb || WITH->blnk != saveb2) { + + if (WITH->UU.b != saveb || WITH->blnk != saveb2) + { drawvalue(V.p, false, &V); touched = true; } @@ -8801,9 +8853,12 @@ end; */ savei = WITH->UU.nv; if (WITH->UU.nv < V.kattr[V.p - 1].UU.U86.nv - 1) WITH->UU.nv++; + if (!tryconfig(&V)) WITH->UU.nv = savei; - if (WITH->UU.nv != savei) { + + if (WITH->UU.nv != savei) + { maskvalues(&V); drawvalue(V.p, false, &V); touched = true; @@ -8813,37 +8868,51 @@ end; */ } stamp(attrstamp); chpage((int)gg.curpage); - } else if (ch == '\b') { + } + else if (ch == '\b') + { gg.actflag = false; gg.actflag2 = false; callconfig(relproc, &V); - if (!gg.actflag) { - switch (V.kattr[V.p - 1].dtype) { + if (!gg.actflag) + { + switch (V.kattr[V.p - 1].dtype) + { case 'R': case 'U': case 'F': - if (!WITH->blnk) { + if (!WITH->blnk) + { r1 = scrnincr(V.p, &V); saver = WITH->UU.r; WITH->UU.r = cleanup(WITH->UU.r - r1, r1, &V); - if (tryconfig(&V)) { + if (tryconfig(&V)) + { drawvalue(V.p, false, &V); touched = true; - } else + } + else + { WITH->UU.r = saver; + } } break; case 'I': case 'H': - if (!WITH->blnk) { + if (!WITH->blnk) + { WITH->UU.U73.i1--; - if (tryconfig(&V)) { + if (tryconfig(&V)) + { drawvalue(V.p, false, &V); touched = true; - } else + } + else + { WITH->UU.U73.i1++; + } } break; @@ -8857,11 +8926,14 @@ end; */ saveb2 = WITH->blnk; WITH->UU.b = false; WITH->blnk = false; - if (!tryconfig(&V)) { + if (!tryconfig(&V)) + { WITH->UU.b = saveb; WITH->blnk = saveb2; } - if (WITH->UU.b != saveb || WITH->blnk != saveb2) { + + if (WITH->UU.b != saveb || WITH->blnk != saveb2) + { drawvalue(V.p, false, &V); touched = true; } @@ -8871,9 +8943,12 @@ end; */ savei = WITH->UU.nv; if (WITH->UU.nv > 0) WITH->UU.nv--; + if (!tryconfig(&V)) WITH->UU.nv = savei; - if (WITH->UU.nv != savei) { + + if (WITH->UU.nv != savei) + { maskvalues(&V); drawvalue(V.p, false, &V); touched = true; @@ -8883,17 +8958,25 @@ end; */ } stamp(attrstamp); chpage((int)gg.curpage); - } else + } + else + { understood = false; + } } - if (!understood) { + + if (!understood) + { nk_gotoxy(V.kattr[V.p - 1].x, V.kattr[V.p - 1].y - V.ybase); putchar('\t'); + if (ch == '\015') ungetkey2('\003'); else ungetkey2(ch); - switch (V.kattr[V.p - 1].dtype) { + + switch (V.kattr[V.p - 1].dtype) + { case 'R': case 'U': @@ -8906,15 +8989,21 @@ end; */ saver = WITH->UU.r; if (*buf == '\0' || !(buf[0] == '-' || buf[0] == '+' || buf[0] == '.' || - isdigit(buf[0]))) { + isdigit(buf[0]))) + { if (V.kattr[V.p - 1].opt) + { WITH->blnk = true; - else { + } + else + { WITH->blnk = false; WITH->UU.r = V.kattr[V.p - 1].UU.U82.r; } touched = true; - } else { + } + else + { TRY(try16); readreal(buf, &r1); WITH->UU.r = r1; @@ -8926,7 +9015,9 @@ end; */ warning(); ENDTRY(try16); } - if (!tryconfig(&V)) { + + if (!tryconfig(&V)) + { WITH->UU.r = saver; WITH->blnk = saveb; touched = saveb2; @@ -8941,15 +9032,21 @@ end; */ saveb = WITH->blnk; savei = WITH->UU.U73.i1; if (*buf == '\0' || - !(buf[0] == '+' || buf[0] == '-' || isdigit(buf[0]))) { + !(buf[0] == '+' || buf[0] == '-' || isdigit(buf[0]))) + { if (V.kattr[V.p - 1].opt) + { WITH->blnk = true; - else { + } + else + { WITH->blnk = false; WITH->UU.U73.i1 = V.kattr[V.p - 1].UU.U73.i1; } touched = true; - } else { + } + else + { TRY(try17); j1 = strtol(buf, &STR2, 10); j = STR2 - buf + 1; @@ -8962,7 +9059,9 @@ end; */ warning(); ENDTRY(try17); } - if (!tryconfig(&V)) { + + if (!tryconfig(&V)) + { WITH->UU.U73.i1 = savei; WITH->blnk = saveb; touched = saveb2; @@ -8978,15 +9077,21 @@ end; */ savei = WITH->UU.U73.i1; if (*buf == '\0' || !((buf[0] >= 'a' && buf[0] <= 'f') || - (buf[0] >= 'A' && buf[0] <= 'F') || isdigit(buf[0]))) { + (buf[0] >= 'A' && buf[0] <= 'F') || isdigit(buf[0]))) + { if (V.kattr[V.p - 1].opt) + { WITH->blnk = true; - else { + } + else + { WITH->blnk = false; WITH->UU.U73.i1 = V.kattr[V.p - 1].UU.U73.i1; } touched = true; - } else { + } + else + { TRY(try18); WITH->UU.U73.i1 = strtol(buf, NULL, 16); WITH->blnk = false; @@ -8997,7 +9102,9 @@ end; */ warning(); ENDTRY(try18); } - if (!tryconfig(&V)) { + + if (!tryconfig(&V)) + { WITH->UU.U73.i1 = savei; WITH->blnk = saveb; touched = saveb2; @@ -9011,11 +9118,12 @@ end; */ strcpy(STR1, strltrim(strrtrim(strcpy(STR3, buf)))); strcpy(buf, STR1); if (*buf == '\0' && !V.kattr[V.p - 1].opt) + { strcpy(buf, V.kattr[V.p - 1].UU.c); - else if (strlen(buf) > V.kattr[V.p - 1].prec) { + } + else if (strlen(buf) > V.kattr[V.p - 1].prec) + { buf[V.kattr[V.p - 1].prec] = '\0'; - /* p2c: log.text, line 13845: - * Note: Modification of string length may translate incorrectly [146] */ } strcpy(WITH->UU.c, buf); if (tryconfig(&V)) @@ -9045,23 +9153,32 @@ end; */ saveb = WITH->blnk; saveb2 = WITH->UU.b; ch = inkey2(); - if (ch == '1' || ch == 'y' || ch == 'Y' || ch == 't' || ch == 'T') { + if (ch == '1' || ch == 'y' || ch == 'Y' || ch == 't' || ch == 'T') + { WITH->UU.b = true; WITH->blnk = false; - } else if (ch == '0' || ch == 'n' || ch == 'N' || ch == 'f' || - ch == 'F') { + } + else if (ch == '0' || ch == 'n' || ch == 'N' || ch == 'f' || ch == 'F') + { WITH->UU.b = false; WITH->blnk = false; - } else if ((ch == '\003' || ch == '\015' || ch == 'x' || ch == 'X') && - V.kattr[V.p - 1].opt) + } + else if ((ch == '\003' || ch == '\015' || ch == 'x' || ch == 'X') && V.kattr[V.p - 1].opt) + { WITH->blnk = true; - else if (ch == '\003' || ch == '\015' || ch == 'z' || ch == 'Z') { + } + else if (ch == '\003' || ch == '\015' || ch == 'z' || ch == 'Z') + { WITH->UU.b = !WITH->UU.b; WITH->blnk = false; } + if (tryconfig(&V)) + { touched = true; - else { + } + else + { WITH->blnk = saveb; WITH->UU.b = saveb2; } @@ -9075,13 +9192,19 @@ end; */ l1 = V.kattr[V.p - 1].UU.U86.v; while (l1 != NULL && strcicmp(l1->s, buf) != 0) l1 = l1->next; + if (l1 != NULL) WITH->UU.nv = (long)l1->value; - if (tryconfig(&V)) { + + if (tryconfig(&V)) + { maskvalues(&V); touched = true; - } else + } + else + { WITH->UU.nv = savei; + } break; } stamp(attrstamp); @@ -9093,21 +9216,12 @@ end; */ m_graphics_on(); clearalpha(); - /* p2c: log.text, line 13543: Note: Character >= 128 encountered [281] */ - /* p2c: log.text, line 13543: Note: Character >= 128 encountered [281] */ /*ignore*/ } - -static void editattrsx(gattr, numattrs, kattr, lbl, name, proc, chproc, - relproc) - log_gattrrec *gattr; - short numattrs; - log_kattrrec *kattr; - na_strlist_t *lbl; - char *name; - void (*proc) (), (*chproc) (), (*relproc) (); +static void editattrsx(log_fattrrec *gattr, short numattrs, log_kattrrec *kattr, na_strlist *lbl, char *name, + void (*proc) (), void (*chproc) (), void (*relproc()) { long stamp; @@ -9115,7 +9229,6 @@ static void editattrsx(gattr, numattrs, kattr, lbl, name, proc, chproc, } - static void gproc1() { calltool(gg.acttool, act_configgate); @@ -9134,8 +9247,7 @@ static void gproc3() } -static void configgate(g) - log_grec *g; +static void configgate(log_grec *g) { void (*TEMP) (); void (*TEMP5) (); @@ -9169,9 +9281,7 @@ static void nproc3() } -static void confignode(n, name) - log_nrec *n; - char *name; +static void confignode(log_nrec *n, char *name) { void (*TEMP) (); void (*TEMP5) (); @@ -9187,8 +9297,7 @@ static void confignode(n, name) } -static void configkind(i) - short i; +static void configkind(short i) { log_krec *k; log_grec *g; @@ -9197,7 +9306,8 @@ static void configkind(i) return; k = kind[(kindgroup[i - 1] & (log_kindoffset - 1)) - 1]; newgate(&g, kindgroup[i - 1]); - if (kindattr[i - 1] != NULL) { + if (kindattr[i - 1] != NULL) + { disposeattrs(&g->attr, k->numattrs, k->attr); copyattrs(&g->attr, kindattr[i - 1], k->numattrs, k->attr); } @@ -9216,8 +9326,7 @@ struct LOC_setattr { short p; } ; -static int tryconfig_(LINK) - struct LOC_setattr *LINK; +static int tryconfig_(struct LOC_setattr *LINK) { gg.actflag = true; gg.actx = LINK->p; @@ -9227,11 +9336,7 @@ static int tryconfig_(LINK) return (gg.actflag); } -static int setattr(gattr_, kattr_, p_, buf) - log_gattrrec *gattr_; - log_kattrrec *kattr_; - short p_; - char *buf; +static int setattr(log_gattrrec *gattr_, log_kattrrec *kattr_, short p_, char *buf) { struct LOC_setattr V; int touched; @@ -9251,7 +9356,8 @@ static int setattr(gattr_, kattr_, p_, buf) V.p = p_; touched = false; WITH = &V.gattr[V.p - 1]; - switch (V.kattr[V.p - 1].dtype) { + switch (V.kattr[V.p - 1].dtype) + { case 'R': case 'U': @@ -9261,16 +9367,21 @@ static int setattr(gattr_, kattr_, p_, buf) saveb2 = touched; saveb = WITH->blnk; saver = WITH->UU.r; - if (*buf == '\0' || !(buf[0] == '-' || buf[0] == '+' || buf[0] == '.' || - isdigit(buf[0]))) { + if (*buf == '\0' || !(buf[0] == '-' || buf[0] == '+' || buf[0] == '.' || isdigit(buf[0]))) + { if (V.kattr[V.p - 1].opt) + { WITH->blnk = true; - else { + } + else + { WITH->blnk = false; WITH->UU.r = V.kattr[V.p - 1].UU.U82.r; } touched = true; - } else { + } + else + { TRY(try19); readreal(buf, &r1); WITH->UU.r = r1; @@ -9281,7 +9392,9 @@ static int setattr(gattr_, kattr_, p_, buf) _Escape(P_escapecode); ENDTRY(try19); } - if (!tryconfig_(&V)) { + + if (!tryconfig_(&V)) + { WITH->UU.r = saver; WITH->blnk = saveb; touched = saveb2; @@ -9294,15 +9407,21 @@ static int setattr(gattr_, kattr_, p_, buf) saveb2 = touched; saveb = WITH->blnk; savei = WITH->UU.U73.i1; - if (*buf == '\0' || !(buf[0] == '+' || buf[0] == '-' || isdigit(buf[0]))) { + if (*buf == '\0' || !(buf[0] == '+' || buf[0] == '-' || isdigit(buf[0]))) + { if (V.kattr[V.p - 1].opt) + { WITH->blnk = true; - else { + } + else + { WITH->blnk = false; WITH->UU.U73.i1 = V.kattr[V.p - 1].UU.U73.i1; } touched = true; - } else { + } + else + { TRY(try20); j1 = strtol(buf, &STR2, 10); j = STR2 - buf + 1; @@ -9314,7 +9433,9 @@ static int setattr(gattr_, kattr_, p_, buf) _Escape(P_escapecode); ENDTRY(try20); } - if (!tryconfig_(&V)) { + + if (!tryconfig_(&V)) + { WITH->UU.U73.i1 = savei; WITH->blnk = saveb; touched = saveb2; @@ -9329,15 +9450,21 @@ static int setattr(gattr_, kattr_, p_, buf) savei = WITH->UU.U73.i1; if (*buf == '\0' || !((buf[0] >= 'a' && buf[0] <= 'f') || (buf[0] >= 'A' && buf[0] <= 'F') || - isdigit(buf[0]))) { + isdigit(buf[0]))) + { if (V.kattr[V.p - 1].opt) + { WITH->blnk = true; - else { + } + else + { WITH->blnk = false; WITH->UU.U73.i1 = V.kattr[V.p - 1].UU.U73.i1; } touched = true; - } else { + } + else + { TRY(try21); WITH->UU.U73.i1 = strtol(buf, NULL, 16); WITH->blnk = false; @@ -9347,7 +9474,9 @@ static int setattr(gattr_, kattr_, p_, buf) _Escape(P_escapecode); ENDTRY(try21); } - if (!tryconfig_(&V)) { + + if (!tryconfig_(&V)) + { WITH->UU.U73.i1 = savei; WITH->blnk = saveb; touched = saveb2; @@ -9359,13 +9488,15 @@ static int setattr(gattr_, kattr_, p_, buf) strcpy(STR1, strltrim(strrtrim(strcpy(STR3, buf)))); strcpy(buf, STR1); if (*buf == '\0' && !V.kattr[V.p - 1].opt) + { strcpy(buf, V.kattr[V.p - 1].UU.c); - else if (strlen(buf) > V.kattr[V.p - 1].prec) { + } + else if (strlen(buf) > V.kattr[V.p - 1].prec) + { buf[V.kattr[V.p - 1].prec] = '\0'; - /* p2c: log.text, line 14167: - * Note: Modification of string length may translate incorrectly [146] */ } strcpy(WITH->UU.c, buf); + if (tryconfig_(&V)) touched = true; else @@ -9392,24 +9523,32 @@ static int setattr(gattr_, kattr_, p_, buf) saveb2 = WITH->UU.b; if (*buf == '\0') strcpy(buf, " "); - if (buf[0] == '1' || buf[0] == 'y' || buf[0] == 'Y' || buf[0] == 't' || - buf[0] == 'T') { + if (buf[0] == '1' || buf[0] == 'y' || buf[0] == 'Y' || buf[0] == 't' || buf[0] == 'T') + { WITH->UU.b = true; WITH->blnk = false; - } else if (buf[0] == '0' || buf[0] == 'n' || buf[0] == 'N' || - buf[0] == 'f' || buf[0] == 'F') { + } + else if (buf[0] == '0' || buf[0] == 'n' || buf[0] == 'N' || buf[0] == 'f' || buf[0] == 'F') + { WITH->UU.b = false; WITH->blnk = false; - } else if ((buf[0] == 'x' || buf[0] == 'X' || buf[0] == ' ') && - V.kattr[V.p - 1].opt) + } + else if ((buf[0] == 'x' || buf[0] == 'X' || buf[0] == ' ') && V.kattr[V.p - 1].opt) + { WITH->blnk = true; - else if (buf[0] == 'z' || buf[0] == 'Z' || buf[0] == ' ') { + } + else if (buf[0] == 'z' || buf[0] == 'Z' || buf[0] == ' ') + { WITH->UU.b = !WITH->UU.b; WITH->blnk = false; } + if (tryconfig_(&V)) + { touched = true; - else { + } + else + { WITH->blnk = saveb; WITH->UU.b = saveb2; } @@ -9422,8 +9561,10 @@ static int setattr(gattr_, kattr_, p_, buf) l1 = V.kattr[V.p - 1].UU.U86.v; while (l1 != NULL && strcicmp(l1->s, buf) != 0) l1 = l1->next; + if (l1 != NULL) WITH->UU.nv = (long)l1->value; + if (tryconfig_(&V)) touched = true; else @@ -9434,10 +9575,7 @@ static int setattr(gattr_, kattr_, p_, buf) } -static void setgattr(g, num, value_) - log_grec *g; - short num; - char *value_; +static void setgattr(log_grec *g, short num, char *value_) { char value[256]; log_grec *g1; @@ -9452,11 +9590,13 @@ static void setgattr(g, num, value_) gg.actnode = NULL; gg.acttool = g->kind->simtype; gg.action = act_configchgate; - if (setattr(g->attr, g->kind->attr, num, value)) { + if (setattr(g->attr, g->kind->attr, num, value)) + { stamp(&gg.gattrstamp); g1 = NULL; pg = gg.numpages + 1; - while (pg > 1 && g1 != NULL) { + while (pg > 1 && g1 != NULL) + { pg--; g1 = gg.gbase[pg - 1]; while (g1 != NULL && g1 != g) @@ -9469,11 +9609,7 @@ static void setgattr(g, num, value_) } - -static void setnattr(n, num, value_) - log_nrec *n; - short num; - char *value_; +static void setnattr(log_nrec *n, short num, char *value_) { char value[256]; log_tool *saveacttool; @@ -9504,8 +9640,7 @@ const fliparr flips = { }; -static short doflip(rot, mode) - short rot, mode; +static short doflip(short rot, short mode) { return (flips[mode][rot]); } @@ -9517,22 +9652,26 @@ static short doflip(rot, mode) /*= =*/ /*================================================*/ -static void flipgate(g) - log_grec *g; +static void flipgate(log_grec *g) { short i; log_krec *WITH; - if (g->kind->flag.U3.noflip) { + if (g->kind->flag.U3.noflip) + { configgate(g); return; } + WITH = g->kind; + if (g->kind->flag.U3.toggle) i = 0; else i = cureditmode; - switch (i) { + + switch (i) + { case 0: case 1: @@ -9546,7 +9685,8 @@ static void flipgate(g) g->g = g->rot * log_kindoffset + (g->g & (log_kindoffset - 1)); drawgatex(g); clipoff(); - if (!connectgate(g)) { + if (!connectgate(g)) + { frygate(g); disposegate(&g); } @@ -9561,7 +9701,6 @@ static void flipgate(g) } - /*================== FLIPKIND ==================*/ /*= =*/ /*= Flip a gate in menu area. =*/ @@ -9575,14 +9714,19 @@ static void flipkind() remcursor(); i = (gg.t.x - kindgroupleft) / kindgroupspacing + 1; k = kindgroup[i - 1] & (log_kindoffset - 1); - if (kindgroup[i - 1] != 0 && !kind[k - 1]->flag.U3.noflip) { + if (kindgroup[i - 1] != 0 && !kind[k - 1]->flag.U3.noflip) + { clipoff(); kdrawgatec(i, gg.color.backgr); z = kindgroup[i - 1] / log_kindoffset; if (kind[k - 1]->flag.U3.named) + { z = doflip(z, 2); - else { - switch (cureditmode) { + } + else + { + switch (cureditmode) + { case 1: case 2: @@ -9607,9 +9751,7 @@ static void flipkind() /*= =*/ /*================================================*/ -static void settofrom(g, name) - log_grec **g; - char *name; +static void settofrom(log_grec **g, char *name) { if (!(*g)->kind->flag.U3.named) return; @@ -9618,7 +9760,8 @@ static void settofrom(g, name) eragate(*g); clipoff(); (*g)->sig = getsignal((*g)->sig, name); - if (connectgate(*g)) { + if (connectgate(*g)) + { clipon(); drawgatex(*g); clipoff(); @@ -9630,8 +9773,7 @@ static void settofrom(g, name) } -static void adjustsignal(g) - log_grec *g; +static void adjustsignal(log_grec *g) { char n[256]; uchar ch; @@ -9643,26 +9785,31 @@ static void adjustsignal(g) rightface = (g->kind->flag.U3.nright != (g->rot == 0)); gsignallabel(g->x, g->y, g, gg.color.backgr); *n = '\0'; - do { + do + { if (strlen(n) < 256-1) strcat(n, "_"); remcursor(); m_colormode((long)m_xor); m_color((long)gg.color.signal); - if (rightface) { - /* p2c: log.text, line 14457: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ + if (rightface) + { drawstr2((int)(g->x * gg.scale - gg.xoff - m_strwidth(logfont_lfont, strrtrim(strcpy(STR1, n))) + NAMEGAP), (int)(g->y * gg.scale - gg.yoff - 3), strrtrim(strcpy(STR2, n))); - } else + } + else + { drawstr2((int)(g->x * gg.scale - gg.xoff - NAMEGAP), (int)(g->y * gg.scale - gg.yoff - 3), strrtrim(strcpy(STR1, n))); + } m_colormode((long)m_normal); - if (!pollkbd2()) { - do { + if (!pollkbd2()) + { + do + { pass(); pen(); } while (!(pollkbd2() || gg.t.dn)); @@ -9670,53 +9817,56 @@ static void adjustsignal(g) remcursor(); m_colormode((long)m_xor); m_color((long)gg.color.signal); - if (rightface) { - /* p2c: log.text, line 14471: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ + if (rightface) + { drawstr2((int)(g->x * gg.scale - gg.xoff - m_strwidth(logfont_lfont, strrtrim(strcpy(STR1, n))) + NAMEGAP), (int)(g->y * gg.scale - gg.yoff - 3), strrtrim(strcpy(STR2, n))); - } else + } + else + { drawstr2((int)(g->x * gg.scale - gg.xoff - NAMEGAP), (int)(g->y * gg.scale - gg.yoff - 3), strrtrim(strcpy(STR1, n))); + } m_colormode((long)m_normal); n[strlen(n) - 1] = '\0'; - if (pollkbd2()) { + if (pollkbd2()) + { ch = inkey2(); if ((strlen(n) < 256-2 && ch > ' ' && ch != 250 && ch != 251) || (ch == ' ' && *n != '\0')) sprintf(n + strlen(n), "%c", ch); - /* p2c: log.text, line 14480: Note: Character >= 128 encountered [281] */ - /* p2c: log.text, line 14480: Note: Character >= 128 encountered [281] */ + if (ch == '\007' && *n != '\0') n[strlen(n) - 1] = '\0'; } } while (!((ch < 32 && ((1L << ch) & 0x2008) != 0) || gg.t.dn)); remcursor(); m_color((long)gg.color.signal); - if (rightface) { - /* p2c: log.text, line 14490: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ + if (rightface) + { drawstr2((int)(g->x * gg.scale - gg.xoff - m_strwidth(logfont_lfont, strrtrim(strcpy(STR1, n))) + NAMEGAP), (int)(g->y * gg.scale - gg.yoff - 3), strrtrim(strcpy(STR2, n))); - } else + } + else + { drawstr2((int)(g->x * gg.scale - gg.xoff - NAMEGAP), (int)(g->y * gg.scale - gg.yoff - 3), strrtrim(strcpy(STR1, n))); + } settofrom(&g, n); signalcaps = nk_setcapslock(savecaps); } - -static void touchgate(g) - log_grec *g; +static void touchgate(log_grec *g) { short xx, yy; - if (g->kind->flag.U3.named) { + if (g->kind->flag.U3.named) + { adjustsignal(g); return; } @@ -9730,6 +9880,7 @@ static void touchgate(g) gg.acty2 = log_irotxy[g->rot] * xx + log_irotyy[g->rot] * yy; gg.actflag = false; calltoolgate(g, act_touchgate); + if (gg.actflag) chpageplace((int)gg.curpage, g->x - g->kind->bbmax, g->y - g->kind->bbmax, g->x + g->kind->bbmax, g->y + g->kind->bbmax); @@ -9760,9 +9911,7 @@ static void unsoldernear() } -static void unsolderwires(hw, vw) - log_hwrec *hw; - log_vwrec *vw; +static void unsolderwires(log_hwrec *hw, log_vwrec *vw) { if (hw == NULL || vw == NULL) return; @@ -9774,7 +9923,8 @@ static void unsolderwires(hw, vw) static void soldernear() { - if (!trycombinenodes(&gg.nearvw->node, &gg.nearhw->node)) { + if (!trycombinenodes(&gg.nearvw->node, &gg.nearhw->node)) + { frysolder(gg.nearvw->x, gg.nearhw->y); return; } @@ -9784,8 +9934,7 @@ static void soldernear() } -static void solderat(x, y) - short x, y; +static void solderat(short x, short y) { if (findsolder(x, y) != NULL) return; @@ -9796,68 +9945,65 @@ static void solderat(x, y) } -static void findattrnum2(numattrs, kattr, lbl, name, kinds, num) - short numattrs; - log_kattrrec *kattr; - na_strlist_t *lbl; - char *name, *kinds; - short *num; +static void findattrnum2(short numattrs, log_kattrec *kattr, na_strlist_t *lbl, char *name, char *kinds, short *num) { na_strlist_t *l1; - if (strsubset(name, "0123456789")) { + if (strsubset(name, "0123456789")) + { if (*name == '\0') *num = 0; else *num = strtol(name, NULL, 0); - } else { + } + else + { l1 = lbl; while (l1 != NULL && l1->kind != '\001') l1 = l1->next; + if (l1 != NULL) l1 = strlist_find((na_strlist_t *)l1->value, name); + if (l1 != NULL) *num = (long)l1->value; else *num = 0; } + if (*num < 1 || *num > numattrs || (strposc(kinds, kattr[*num - 1].dtype, 1L) == 0 && *kinds != '\0')) *num = 0; } -static void findattrnum(k, name, kinds, num) - log_krec *k; - char *name, *kinds; - short *num; +static void findattrnum(log_krec *k, char *name, char *kinds, short *num) { findattrnum2(k->numattrs, k->attr, k->lbl, name, kinds, num); } - -static void findattrname2(numattrs, kattr, lbl, num, name) - short numattrs; - log_kattrrec *kattr; - na_strlist_t *lbl; - short num; - char *name; +static void findattrname2(short numattrs, log_kattrrec *kattr, na_strlist_t *lbl, short num, char *name) { na_strlist_t *l1; - if (num < 1 || num > numattrs) { + if (num < 1 || num > numattrs) + { *name = '\0'; return; } l1 = lbl; + while (l1 != NULL && l1->kind != '\001') l1 = l1->next; - if (l1 != NULL) { + + if (l1 != NULL) + { l1 = (na_strlist_t *)l1->value; while (l1 != NULL && (long)l1->value != num) l1 = l1->next; } + if (l1 != NULL) strcpy(name, l1->s); else @@ -9865,27 +10011,24 @@ static void findattrname2(numattrs, kattr, lbl, num, name) } -static void findattrname(k, num, name) - log_krec *k; - short num; - char *name; +static void findattrname(log_krec *k, short num, char *name) { findattrname2(k->numattrs, k->attr, k->lbl, num, name); } -static void findpinnum(k, name_, num) - log_krec *k; - char *name_; - short *num; +static void findpinnum(log_krec *k, char *name_, short *num) { char name[256]; strcpy(name, name_); if (*name == '#') strcpy_overlap(name, name + 1); - if (strsubset(name, "0123456789")) { - if (*name == '\0') { + + if (strsubset(name, "0123456789")) + { + if (*name == '\0') + { *num = 0; return; } @@ -9903,15 +10046,14 @@ static void findpinnum(k, name_, num) } -static void findpinname(k, num, name) - log_krec *k; - short num; - char *name; +static void findpinname(log_krec *k, short num, char *name) { - if (num >= 1 && num <= k->numpins && k->pinnames[num - 1] != NULL) { + if (num >= 1 && num <= k->numpins && k->pinnames[num - 1] != NULL) + { strcpy(name, k->pinnames[num - 1]->s); return; } + if (num == 0) *name = '\0'; else @@ -9919,35 +10061,33 @@ static void findpinname(k, num, name) } -static void findpointmarker(k, num, x, y) - log_krec *k; - short num, *x, *y; +static void findpointmarker(log_krec *k, short num, short *x, short *y) { long i; i = k->numvects; - while (i >= 1 && (k->vector[i - 1].vkind != 'p' || - k->vector[i - 1].UU.U98.num != num)) + while (i >= 1 && (k->vector[i - 1].vkind != 'p' || k->vector[i - 1].UU.U98.num != num)) i--; - if (i >= 1) { + + if (i >= 1) + { *x = k->vector[i - 1].x1; *y = k->vector[i - 1].y1; } } -static void findboxmarker(k, num, x1, y1, x2, y2) - log_krec *k; - short num, *x1, *y1, *x2, *y2; +static void findboxmarker(log_krec *k, short num, short *x1, short *y1, short *x2, short *y2) { long i; i = k->numvects; - while (i >= 1 && (k->vector[i - 1].vkind != 'b' || - k->vector[i - 1].UU.U98.num != num)) + while (i >= 1 && (k->vector[i - 1].vkind != 'b' || k->vector[i - 1].UU.U98.num != num)) i--; + if (i < 1) return; + k->x1 = k->vector[i - 1].x1; k->y1 = k->vector[i - 1].y1; k->x2 = k->vector[i - 1].UU.U99.x2; @@ -9955,9 +10095,7 @@ static void findboxmarker(k, num, x1, y1, x2, y2) } -static void addlabelat(x, y, s) - short x, y; - char *s; +static void addlabelat(short x, short y, char *s) { log_lrec *l; @@ -9966,24 +10104,17 @@ static void addlabelat(x, y, s) l->x = x; l->y = y; l->w = m_strwidth(logfont_lfont, s) / log_scale0; - /* p2c: log.text, line 14764: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ chpageplace((int)gg.curpage, x, y, x + l->w, y + 2); remcursor(); clipon(); m_color((long)gg.color.labeltext); - /* p2c: log.text, line 14769: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ - m_drawstr(x * gg.scale - gg.xoff, y * gg.scale - gg.yoff + 2, logfont_lfont, - s); + m_drawstr(x * gg.scale - gg.xoff, y * gg.scale - gg.yoff + 2, logfont_lfont, s); clipoff(); gg.nearlabel = l; } -static void addlabel(l, s) - log_lrec **l; - char *s; +static void addlabel(log_lrec **l, char *s) { int conflict; log_lrec *l1; @@ -9991,19 +10122,24 @@ static void addlabel(l, s) x = 0; y = baseline - 15; - do { + do + { fixxy(&x, &y); conflict = false; l1 = gg.lbase[gg.curpage - 1]; - while (l1 != NULL) { + while (l1 != NULL) + { if (l1->y * gg.scale - gg.yoff == y && labs(l1->x * gg.scale - gg.xoff - x) < 20) conflict = true; l1 = l1->next; } - if (conflict) { + + if (conflict) + { y -= gg.scale * 2; - if (y < 10) { + if (y < 10) + { y = baseline - 15; x += gg.scale * 20; } @@ -10027,8 +10163,7 @@ static void addlabel(l, s) /*= =*/ /*================================================*/ -static void editlabel(l) - log_lrec *l; +static void editlabel(log_lrec *l) { short i, x1, y1; long j; @@ -10049,38 +10184,42 @@ static void editlabel(l) y1 = l->y * gg.scale - gg.yoff + 2; i = 1; strcpy(name, l->name); - if (touching) { + if (touching) + { while (i <= strlen(name) && gg.t.x - x1 > m_strwidth(logfont_lfont, - (sprintf(STR1, "%.*s", i, name), STR1))) { - /* p2c: log.text, line 14851: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ + (sprintf(STR1, "%.*s", i, name), STR1))) + { i++; } } - do { - do { + + do + { + do + { remcursor(); clipon(); m_colormode((long)m_xor); m_color((long)gg.color.labeltext); sprintf(STR1, "%.*s", i - 1, name); - /* p2c: log.text, line 14860: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ m_move(x1 + m_strwidth(logfont_lfont, STR1) - 1, y1 + 8L); if (i > strlen(name)) + { m_drawrel(6L, 0L); - else { + } + else + { sprintf(STR1, "%.1s", name + i - 1); - /* p2c: log.text, line 14864: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ m_drawrel(m_strwidth(logfont_lfont, STR1), 0L); } m_colormode((long)m_normal); clipoff(); j = timers_sysclock() + blinkrate; - if (!pollkbd2()) { - do { + if (!pollkbd2()) + { + do + { pass(); pen(); } while (!(pollkbd2() || gg.t.dn || timers_sysclock() > j)); @@ -10090,82 +10229,109 @@ static void editlabel(l) m_colormode((long)m_xor); m_color((long)gg.color.labeltext); sprintf(STR1, "%.*s", i - 1, name); - /* p2c: log.text, line 14877: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ m_move(x1 + m_strwidth(logfont_lfont, STR1) - 1, y1 + 8L); if (i > strlen(name)) + { m_drawrel(6L, 0L); - else { + } + else + { sprintf(STR1, "%.1s", name + i - 1); - /* p2c: log.text, line 14881: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ m_drawrel(m_strwidth(logfont_lfont, STR1), 0L); } m_colormode((long)m_normal); clipoff(); j = timers_sysclock() + blinkrate; - if (!(pollkbd2() || gg.t.dn)) { - do { + if (!(pollkbd2() || gg.t.dn)) + { + do + { pass(); pen(); } while (!(pollkbd2() || gg.t.dn || timers_sysclock() > j)); } } while (!(pollkbd2() || gg.t.dn)); - if (!gg.t.dn) { + + if (!gg.t.dn) + { ch = inkey2(); - if (ch >= 32 || ((1L << ch) & 0x10002108L) == 0) { + if (ch >= 32 || ((1L << ch) & 0x10002108L) == 0) + { remcursor(); m_color((long)gg.color.backgr); - /* p2c: log.text, line 14898: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ m_drawstr((long)x1, (long)y1, logfont_lfont, name); redraw = true; - } else + } + else + { redraw = false; - if (ch >= ' ' && ch != 250 && ch != 251 && strlen(name) < log_lablen) { - /* p2c: log.text, line 14903: Note: Character >= 128 encountered [281] */ - /* p2c: log.text, line 14903: Note: Character >= 128 encountered [281] */ - if (i <= strlen(name)) { + } + + if (ch >= ' ' && ch != 250 && ch != 251 && strlen(name) < log_lablen) + { + if (i <= strlen(name)) + { sprintf(STR1, " %s", name + i - 1); strcpy(name + i - 1, STR1); - } else + } + else + { strcat(name, " "); + } name[i - 1] = ch; i++; - } else if (ch == '\007' && i > 1) { + } + else if (ch == '\007' && i > 1) + { i--; strcpy_overlap(name + i - 1, name + i); - } else if (ch == '\030' && i <= strlen(name)) + } + else if (ch == '\030' && i <= strlen(name)) + { strcpy_overlap(name + i - 1, name + i); + } else if (ch == '\b' && i > 1) + { i--; + } else if (ch == '\034' && i <= strlen(name)) + { i++; + } else if (ch == '\031') + { i = 1; + } else if (ch == '\032') + { i = strlen(name) + 1; - else if (ch == '\n' && strlen(name) < log_lablen) { + } + else if (ch == '\n' && strlen(name) < log_lablen) + { sprintf(STR1, " %s", name + i - 1); strcpy(name + i - 1, STR1); - } else if (ch == '\037' && i <= strlen(name) && strlen(name) > 1) + } + else if (ch == '\037' && i <= strlen(name) && strlen(name) > 1) + { strcpy_overlap(name + i - 1, name + i); - if (redraw) { + } + if (redraw) + { remcursor(); m_color((long)gg.color.labeltext); - /* p2c: log.text, line 14950: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ m_drawstr((long)x1, (long)y1, logfont_lfont, name); } } } while (!((ch < 32 && ((1L << ch) & 0x2008) != 0) || gg.t.dn)); + if (*name == '\0') + { displabel(&l); - else if (strcmp(name, l->name)) { + } + else if (strcmp(name, l->name)) + { strcpy(l->name, name); l->w = m_strwidth(logfont_lfont, l->name) / log_scale0; - /* p2c: log.text, line 14961: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ stamp(&gg.labelstamp); chpageplace((int)gg.curpage, l->x, l->y, l->x + l->w, l->y + 2); } @@ -10183,8 +10349,7 @@ static void editlabel(l) /*= =*/ /*================================================*/ -static void addboxat(x1, y1, x2, y2) - short x1, y1, x2, y2; +static void addboxat(short x1, short y1, short x2, short y2) { log_brec *b; @@ -10204,7 +10369,6 @@ static void addboxat(x1, y1, x2, y2) } - static void addbox() { short x1, y1; @@ -10213,18 +10377,22 @@ static void addbox() clearfunc(); cursortype = boxcursor; waitnear(); - do { - do { + do + { + do + { pass(); trykbdscroll(); pen(); } while (!gg.t.dn && gg.stillnear && *gg.func == '\0'); gg.posx = gg.gridx; gg.posy = gg.gridy; - if (gg.incircuit && gg.stillnear && *gg.func == '\0') { + if (gg.incircuit && gg.stillnear && *gg.func == '\0') + { x1 = gg.posx; y1 = gg.posy; - do { + do + { pen(); x1 = gg.gridx; y1 = gg.gridy; @@ -10234,12 +10402,13 @@ static void addbox() rect(gg.posx, gg.posy, x1, y1); m_linestyle(0L); m_colormode((long)m_normal); - do { + do + { pass(); trykbd(); pen(); - } while (gg.gridx == x1 && gg.gridy == y1 && gg.t.depressed && - *gg.func == '\0'); + } while (gg.gridx == x1 && gg.gridy == y1 && gg.t.depressed && *gg.func == '\0'); + m_colormode((long)m_xor); m_color((long)gg.color.dashbox); m_linestyle(1L); @@ -10247,8 +10416,7 @@ static void addbox() m_linestyle(0L); m_colormode((long)m_normal); scroll(); - } while (gg.t.depressed || abs(x1 - gg.posx) < 2 || - abs(y1 - gg.posy) < 2); + } while (gg.t.depressed || abs(x1 - gg.posx) < 2 || abs(y1 - gg.posy) < 2); sortshints(&gg.posx, &x1); sortshints(&gg.posy, &y1); remcursor(); @@ -10258,7 +10426,8 @@ static void addbox() } while (gg.incircuit && gg.stillnear && *gg.func == '\0'); gg.startpoint = false; log_setmode(""); - if (gg.t.dn && !gg.incircuit) { + if (gg.t.dn && !gg.incircuit) + { gg.t.dn = false; gg.t.depressed = false; } @@ -10266,7 +10435,6 @@ static void addbox() } - static void initcolors (); /* Local variables for doshellescape: */ @@ -10274,21 +10442,21 @@ struct LOC_doshellescape { long oldc; } ; -static void recov(LINK) - struct LOC_doshellescape *LINK; +static void recov(struct LOC_doshellescape *LINK) { nk_settransarray(nk_ktsupplied, &curkeytrans); initscreen2(); + if (m_maxcolor != LINK->oldc) initcolormap(); + m_init_pen(tabletaddr); initcolors(); refrscreen(); } -static void doshellescape(arg) - char *arg; +static void doshellescape(char *arg) { struct LOC_doshellescape V; nk_keytransinfo *ktemp; @@ -10308,7 +10476,8 @@ static void doshellescape(arg) i = P_escapecode; j = P_ioresult; recov(&V); - if (i != -20) { + if (i != -20) + { beginerror(); puts(_ShowEscape(STR1, i, j, "During shell escape")); enderror(); @@ -10328,16 +10497,16 @@ static void dumphistory() hn = gg.hnbase; i = 0; printf("Time "); - while (hn != NULL) { - printf("%s%*c", - gg.signaltab[hn->sig - 1].name, - (int)(15 - strlen(gg.signaltab[hn->sig - 1].name)), ' '); + while (hn != NULL) + { + printf("%s%*c", gg.signaltab[hn->sig - 1].name, (int)(15 - strlen(gg.signaltab[hn->sig - 1].name)), ' '); hn = hn->next; i++; } putchar('\n'); ht = gg.htbase; - while (ht != NULL) { + while (ht != NULL) + { printf("% .5E ", ht->time); FORLIM = hncount; for (i = 0; i < FORLIM; i++) @@ -10351,14 +10520,12 @@ static void dumphistory() } - /*================ SHOWHISTORY =================*/ /*= =*/ /*= Enter History (Scope) display mode. =*/ /*= =*/ /*================================================*/ - static void reshuffle() { log_hnrec *hn; @@ -10366,7 +10533,8 @@ static void reshuffle() i = 0; hn = gg.hnbase; - while (hn != NULL) { + while (hn != NULL) + { i++; hn->num = i; hn = hn->next; @@ -10381,7 +10549,8 @@ static void histdelsignals() log_hnrec *hn; log_tool *tool; - while (gg.hnbase != NULL) { + while (gg.hnbase != NULL) + { tool = gg.signaltab[gg.hnbase->sig - 1].np->simtype; disposeattrs(&gg.hnbase->attr, tool->hnumattrs, tool->hattr); hn = gg.hnbase->next; @@ -10398,8 +10567,7 @@ static void histdelsignals() #define unit (histdivision / 2) -static void alignsigname(y) - short *y; +static void alignsigname(short *y) { if (histgattr[histalignsigs - 1].UU.b) *y = histdown - (histdown - *y + unit / 2) / unit * unit; @@ -10414,7 +10582,8 @@ static short histaddsignalpos() short y; y = histdivision / 2; - do { + do + { hn = gg.hnbase; while (hn != NULL && (hn->y + histvscale < y - histvscale || hn->y - histvscale > y + histvscale)) @@ -10427,9 +10596,7 @@ static short histaddsignalpos() } -static void histaddsignal(hn, sig, y) - log_hnrec **hn; - short sig, y; +static void histaddsignal(log_hnrec **hn, short sig, short y) { log_tool *tool; @@ -10447,7 +10614,6 @@ static void histaddsignal(hn, sig, y) } - static void hnproc1() { calltool(gg.acttool, act_confighist); @@ -10471,13 +10637,15 @@ static void haproc1() log_gattrrec *WITH; WITH = &histgattr[histcurcount - 1]; - if (WITH->UU.U73.i1 != htcount) { + if (WITH->UU.U73.i1 != htcount) + { WITH->UU.U73.i1 = htcount; WITH->blnk = false; WITH->changed = true; } WITH = &histgattr[histcurtime - 1]; - if (WITH->UU.r != gg.time) { + if (WITH->UU.r != gg.time) + { WITH->UU.r = gg.time; WITH->blnk = false; WITH->changed = true; @@ -10496,7 +10664,8 @@ static void haproc2() log_gattrrec *WITH; WITH = &histgattr[gg.actx - 1]; - switch (gg.actx) { + switch (gg.actx) + { case histtrigsig: if (!strcmp(WITH->UU.c, "(none)")) @@ -10508,7 +10677,9 @@ static void haproc2() case histstarttime: if (WITH->UU.r <= 0) WITH->blnk = true; - if (!WITH->blnk && WITH->UU.r >= histgattr[histstoptime - 1].UU.r) { + + if (!WITH->blnk && WITH->UU.r >= histgattr[histstoptime - 1].UU.r) + { histgattr[histstoptime - 1].blnk = true; histgattr[histstoptime - 1].changed = true; } @@ -10517,7 +10688,9 @@ static void haproc2() case histstoptime: if (WITH->UU.r < 0) WITH->blnk = true; - if (!WITH->blnk && WITH->UU.r <= histgattr[histstarttime - 1].UU.r) { + + if (!WITH->blnk && WITH->UU.r <= histgattr[histstarttime - 1].UU.r) + { histgattr[histstarttime - 1].blnk = true; histgattr[histstarttime - 1].changed = true; } @@ -10600,23 +10773,25 @@ struct LOC_historycommand { long stamp; } ; -static double valueattime(hn, time, LINK) - log_hnrec *hn; - double time; - struct LOC_historycommand *LINK; +static double valueattime(log_hnrec *hn, double time, struct LOC_historycommand *LINK) { log_htrec *ht, *ht0; double v1, v2, alpha; ht = gg.htbase; ht0 = NULL; - while (ht != NULL && ht->time < time) { + while (ht != NULL && ht->time < time) + { ht0 = ht; ht = ht->next; } + if (ht == NULL || ht0 == NULL) + { return 0.0; - else { + } + else + { v1 = na_srtor(ht0->val[hn->num - 1]); v2 = na_srtor(ht->val[hn->num - 1]); alpha = (time - ht0->time) / (ht->time - ht0->time); @@ -10624,40 +10799,45 @@ static double valueattime(hn, time, LINK) } } -static log_hnrec *findtrace(x, y, LINK) - short x, y; - struct LOC_historycommand *LINK; +static log_hnrec *findtrace(short x, short y, struct LOC_historycommand *LINK) { log_htrec *ht, *ht0; double v1, v2, value, alpha, time; log_hnrec *hn, *besthn; short yy, besty; - time = (double)(x - histleft) / histdivision * - histgattr[histsecdiv - 1].UU.r + histgattr[histfirsttime - 1].UU.r; + time = (double)(x - histleft) / histdivision * histgattr[histsecdiv - 1].UU.r + histgattr[histfirsttime - 1].UU.r; ht = gg.htbase; ht0 = NULL; - while (ht != NULL && ht->time < time) { + while (ht != NULL && ht->time < time) + { ht0 = ht; ht = ht->next; } + if (ht == NULL || ht0 == NULL) + { return NULL; - else { + } + else + { alpha = (time - ht0->time) / (ht->time - ht0->time); hn = gg.hnbase; besty = 9999; - while (hn != NULL) { + while (hn != NULL) + { v1 = na_srtor(ht0->val[hn->num - 1]); v2 = na_srtor(ht->val[hn->num - 1]); value = v1 + (v2 - v1) * alpha; historyvaluey(hn, value, &v1, &yy); - if (abs(yy - y) < besty) { + if (abs(yy - y) < besty) + { besty = abs(yy - y); besthn = hn; } hn = hn->next; } + if (besty < tolerance) return besthn; else @@ -10667,8 +10847,7 @@ static log_hnrec *findtrace(x, y, LINK) #undef tolerance -static void refrtrigger(LINK) - struct LOC_historycommand *LINK; +static void refrtrigger(struct LOC_historycommand *LINK) { if (gg.histactive == LINK->oldtrigger || LINK->whichmenu != 0) return; @@ -10682,8 +10861,7 @@ static void refrtrigger(LINK) LINK->oldtrigger = gg.histactive; } -static void refrreset(LINK) - struct LOC_historycommand *LINK; +static void refrreset(struct LOC_historycommand *LINK) { if (gg.resetflag == LINK->oldreset || LINK->whichmenu != 0) return; @@ -10697,31 +10875,34 @@ static void refrreset(LINK) LINK->oldreset = gg.resetflag; } -static void refronoff(LINK) - struct LOC_historycommand *LINK; +static void refronoff(struct LOC_historycommand *LINK) { if (gg.pwrflag == LINK->oldonoff || LINK->whichmenu != 0) return; remcursor(); clipoff(); - if (gg.pwrflag) { + if (gg.pwrflag) + { m_color((long)gg.color.selword); drawstr2((int)onoffpos, LINK->vmenu1, "ON "); - } else { + } + else + { m_color((long)gg.color.menuword); drawstr2((int)onoffpos, LINK->vmenu1, "OFF"); } LINK->oldonoff = gg.pwrflag; } -static void refrgridmode(LINK) - struct LOC_historycommand *LINK; +static void refrgridmode(struct LOC_historycommand *LINK) { - if (histgridmode != LINK->oldgridmode && LINK->whichmenu == 0) { + if (histgridmode != LINK->oldgridmode && LINK->whichmenu == 0) + { remcursor(); clipoff(); m_color((long)gg.color.selword); - switch (histgridmode) { + switch (histgridmode) + { case 0: drawstr2((int)gridpos, LINK->vmenu1, "Delta: "); @@ -10741,11 +10922,13 @@ static void refrgridmode(LINK) } LINK->oldgridmode = histgridmode; } + if (histgridwhich == LINK->oldgridwhich) return; remcursor(); clipoff(); - switch (histgridwhich) { + switch (histgridwhich) + { case 0: m_color((long)gg.color.selword); @@ -10765,8 +10948,7 @@ static void refrgridmode(LINK) LINK->oldgridwhich = histgridwhich; } -static void refrfast(LINK) - struct LOC_historycommand *LINK; +static void refrfast(struct LOC_historycommand *LINK) { int fast; @@ -10783,10 +10965,7 @@ static void refrfast(LINK) LINK->oldfast = fast; } -static void drawsigname(hn, opt, LINK) - log_hnrec *hn; - short opt; - struct LOC_historycommand *LINK; +static void drawsigname(log_hnrec *hn, short opt, struct LOC_historycommand *LINK) { remcursor(); clipoff(); @@ -10794,12 +10973,14 @@ static void drawsigname(hn, opt, LINK) m_colormode((long)m_xor); else m_colormode((long)m_normal); + if (opt == 2) m_color((long)gg.color.backgr); else if (hn == histgridhn && opt != 1) m_color((long)gg.color.selword); else m_color((long)gg.color.signal); + drawstr2(0, hn->y - 4, gg.signaltab[hn->sig - 1].name); m_colormode((long)m_normal); } @@ -10812,26 +10993,24 @@ struct LOC_drawhistory { short *ar; } ; -static void drawtrace(hn, i, LINK) - log_hnrec *hn; - short i; - struct LOC_drawhistory *LINK; +static void drawtrace(log_hnrec *hn, short i, struct LOC_drawhistory *LINK) { historypointy(hn, LINK->ht, &LINK->y); - if ((unsigned long)gg.acty > 15) { + if ((unsigned long)gg.acty > 15) + { LINK->ar[i - 1] = log_maxshint; return; } m_color(gg.acty); - if (LINK->ar[i - 1] != log_maxshint) { + if (LINK->ar[i - 1] != log_maxshint) + { m_move((long)LINK->oldx, (long)LINK->ar[i - 1]); m_draw((long)LINK->x, (long)LINK->y); } LINK->ar[i - 1] = LINK->y; } -static void drawhistory(LINK) - struct LOC_historycommand *LINK; +static void drawhistory(struct LOC_historycommand *LINK) { struct LOC_drawhistory V; short i, gridi; @@ -10841,31 +11020,41 @@ static void drawhistory(LINK) V.LINK = LINK; hn = gg.hnbase; - while (hn != NULL) { + while (hn != NULL) + { if (histgridhn != hn) drawsigname(hn, 0, LINK); hn = hn->next; } + if (histgridhn != NULL) drawsigname(histgridhn, 0, LINK); + if (gg.htbase == NULL) return; + V.ar = (short *)Malloc(hncount * 2); FORLIM = hncount; for (i = 0; i < FORLIM; i++) V.ar[i] = log_maxshint; + m_clip((long)histleft, 0L, (long)across, (long)histdown); V.ht = gg.htbase; ht1 = gg.htbase; - while (ht1 != NULL && ht1->time < histgattr[histfirsttime - 1].UU.r) { + + while (ht1 != NULL && ht1->time < histgattr[histfirsttime - 1].UU.r) + { V.ht = ht1; ht1 = ht1->next; } - do { + + do + { historypointx(V.ht, &V.x); hn = gg.hnbase; i = 0; - while (hn != NULL) { + while (hn != NULL) + { i++; if (histgridhn != hn) drawtrace(hn, i, &V); @@ -10882,9 +11071,7 @@ static void drawhistory(LINK) Free(V.ar); } -static void setgridwhich(hn, LINK) - log_hnrec *hn; - struct LOC_historycommand *LINK; +static void setgridwhich(log_hnrec *hn, struct historycommand *LINK) { if (histgridhn != NULL) drawsigname(histgridhn, 1, LINK); @@ -10897,15 +11084,15 @@ static void setgridwhich(hn, LINK) drawsigname(histgridhn, 0, LINK); } -static void nextgridwhich(LINK) - struct LOC_historycommand *LINK; +static void nextgridwhich(struct LOC_historycommand *LINK) { log_hnrec *nexthn; nexthn = histgridhn; if (nexthn != NULL) drawsigname(nexthn, 1, LINK); - switch (histgridwhich) { + switch (histgridwhich) + { case 0: histgridwhich = 1; @@ -10930,8 +11117,7 @@ static void nextgridwhich(LINK) drawsigname(histgridhn, 0, LINK); } -static void nextgridmode(LINK) - struct LOC_historycommand *LINK; +static void nextgridmode(struct LOC_historycommand *LINK) { if (histgridmode == 0) histgridmode = 3; @@ -10939,8 +11125,7 @@ static void nextgridmode(LINK) histgridmode--; } -static void confighistmode(LINK) - struct LOC_historycommand *LINK; +static void confighistmode(struct LOC_historycommand *LINK) { int flag; log_hnrec *hn; @@ -10957,14 +11142,14 @@ static void confighistmode(LINK) if (flag) return; hn = gg.hnbase; - while (hn != NULL) { + while (hn != NULL) + { alignsigname(&hn->y); hn = hn->next; } } -static void passetc(LINK) - struct LOC_historycommand *LINK; +static void passetc(struct LOC_historycommand *LINK) { m_noclip(); refrtrigger(LINK); @@ -10975,8 +11160,7 @@ static void passetc(LINK) pen(); } -static void fastmode(LINK) - struct LOC_historycommand *LINK; +static void fastmode(struct LOC_historycommand *LINK) { long t0; @@ -10988,8 +11172,7 @@ static void fastmode(LINK) gg.fastspeed = gg.fastmax; } -static void dumpcmd(LINK) - struct LOC_historycommand *LINK; +static void dumpcmd(struct LOC_historycommand *LINK) { char fn[256]; log_htrec *ht; @@ -11001,11 +11184,13 @@ static void dumpcmd(LINK) if (gg.htbase == NULL) return; + m_color((long)gg.color.selword); drawstr2((int)dumppos, LINK->vmenu1, "Dump"); beginbottom(); m_alpha_on(); printf("Dump file name"); + if (*dumpfname != '\0') printf(" [%s]", dumpfname); printf(": "); @@ -11013,10 +11198,12 @@ static void dumpcmd(LINK) endbottom(); beginbottom(); m_alpha_on(); + if (*fn != '\0') setdumpname(fn); else printf("Dump file is %s\n", dumpfname); + if (*dumpfname != '\0') { TRY(try23); @@ -11037,7 +11224,10 @@ static void dumpcmd(LINK) dumpmessage("(TITLE: TIME )"); dumpmessage("(POINTS:"); ht = gg.htbase; - while (ht != NULL) { /*list of time values*/ + + /* list of time values */ + while (ht != NULL) + { sprintf(STR2, "%g", ht->time); dumpmessage(STR2); ht = ht->next; @@ -11045,13 +11235,19 @@ static void dumpcmd(LINK) dumpmessage("))"); hn = gg.hnbase; FORLIM = hncount; - for (i = 0; i < FORLIM; i++) { /*for each trace...*/ + + /* for each trace... */ + for (i = 0; i < FORLIM; i++) + { dumpmessage("(DATA:"); /*write its name*/ sprintf(STR3, "(TITLE: \\\\%s\\)", gg.signaltab[hn->sig - 1].name); dumpmessage(STR3); dumpmessage("(POINTS:"); ht = gg.htbase; - while (ht != NULL) { /*and list of values*/ + + /* and list of values */ + while (ht != NULL) + { sprintf(STR3, "%g", na_srtor(ht->val[i])); dumpmessage(STR3); ht = ht->next; @@ -11079,16 +11275,13 @@ static void dumpcmd(LINK) LINK->rflag = true; } -static void refraxis(pos, name, expr, flag, LINK) - long pos; - char *name, *expr; - int flag; - struct LOC_historycommand *LINK; +static void refraxis(long pos, char *name, char *expr, int flag, struct LOC_historycommand *LINK) { if (flag) m_color((long)gg.color.selword); else m_color((long)gg.color.menuword); + drawstr2((int)pos, LINK->vmenu1, name); uerase((int)pos, LINK->vmenu2 - 2, (int)(pos + axiswidth - 3), LINK->vmenu2 + 12); @@ -11098,18 +11291,16 @@ static void refraxis(pos, name, expr, flag, LINK) m_noclip(); } -static void refraxes(LINK) - struct LOC_historycommand *LINK; +static void refraxes(struct LOC_historycommand *LINK) { refraxis(xaxispos, "X-axis", LINK->xexpr, LINK->xactive, LINK); refraxis(yaxispos, "Y-axis", LINK->yexpr, LINK->yactive, LINK); } -static void setaxis(expr, LINK) - char *expr; - struct LOC_historycommand *LINK; +static void setaxis(char *expr, struct LOC_historycommand *LINK) { - if (LINK->xactive) { + if (LINK->xactive) + { LINK->xactive = false; strcpy(LINK->xexpr, expr); if (*LINK->yexpr == '\0') @@ -11117,8 +11308,10 @@ static void setaxis(expr, LINK) refraxes(LINK); return; } + if (!LINK->yactive) return; + LINK->yactive = false; strcpy(LINK->yexpr, expr); if (*LINK->xexpr == '\0') @@ -11126,8 +11319,7 @@ static void setaxis(expr, LINK) refraxes(LINK); } -static void getexpr(LINK) - struct LOC_historycommand *LINK; +static void getexpr(struct LOC_historycommand *LINK) { char expr[256]; @@ -11143,8 +11335,7 @@ static void getexpr(LINK) setaxis(expr, LINK); } -static void plotcmd(LINK) - struct LOC_historycommand *LINK; +static void plotcmd(struct LOC_hostorycommand *LINK) { char STR1[256]; @@ -11157,12 +11348,12 @@ static void plotcmd(LINK) LINK->rflag = true; } -static void measurecmd(LINK) - struct LOC_historycommand *LINK; +static void measurecmd(struct LOC_historycommand *LINK) { char STR1[81]; - do { + do + { while ((gg.t.x < histleft || gg.t.y > histdown) && gg.t.depressed) pen(); LINK->gridx2 = gg.t.x; @@ -11170,20 +11361,21 @@ static void measurecmd(LINK) m_colormode((long)m_xor); m_color((long)gg.color.scroll); *LINK->gridstr = '\0'; - if (histgridwhich == 2) { + if (histgridwhich == 2) + { gg.actx = histgridhn->sig; gg.actgattr = histgridhn->attr; } *gg.actstr = '\0'; gg.acty = histgridmode; - switch (histgridwhich * 100 + histgridmode) { + switch (histgridwhich * 100 + histgridmode) + { case 0: m_drawline((long)LINK->gridx1, 0L, (long)LINK->gridx1, (long)histdown); m_drawline((long)LINK->gridx2, 0L, (long)LINK->gridx2, (long)histdown); gg.actval = (double)abs(LINK->gridx2 - LINK->gridx1) / histdivision; - realunit(LINK->gridstr, gg.actval * histgattr[histsecdiv - 1].UU.r, 4, - "s", true); + realunit(LINK->gridstr, gg.actval * histgattr[histsecdiv - 1].UU.r, 4, "s", true); break; case 1: @@ -11193,8 +11385,7 @@ static void measurecmd(LINK) m_drawline((long)LINK->gridx2, 0L, (long)LINK->gridx2, (long)histdown); gg.actval = (double)(LINK->gridx2 - histleft) / histdivision; realunit(LINK->gridstr, gg.actval * histgattr[histsecdiv - 1].UU.r + - histgattr[histfirsttime - 1].UU.r, 4, "s", - true); + histgattr[histfirsttime - 1].UU.r, 4, "s", true); break; case 3: @@ -11209,19 +11400,17 @@ static void measurecmd(LINK) gg.actval = (double)abs(LINK->gridx2 - LINK->gridx1) / histdivision; if (gg.actval != 0) realunit(LINK->gridstr, - 1 / (gg.actval * histgattr[histsecdiv - 1].UU.r), 4, "Hz", - true); + 1 / (gg.actval * histgattr[histsecdiv - 1].UU.r), 4, "Hz", true); break; case 200: - m_drawline((long)histleft, (long)LINK->gridy1, (long)across, - (long)LINK->gridy1); - m_drawline((long)histleft, (long)LINK->gridy2, (long)across, - (long)LINK->gridy2); + m_drawline((long)histleft, (long)LINK->gridy1, (long)across, (long)LINK->gridy1); + m_drawline((long)histleft, (long)LINK->gridy2, (long)across, (long)LINK->gridy2); gg.actval2 = (double)LINK->gridy1 / histdivision; gg.actval3 = (double)LINK->gridy2 / histdivision; gg.actval = fabs(gg.actval3 - gg.actval2); calltoolnode(gg.signaltab[gg.actx - 1].np, act_histstr); + if (*gg.actstr == '\0') realunit(LINK->gridstr, gg.actval, 4, "", true); else @@ -11229,10 +11418,10 @@ static void measurecmd(LINK) break; case 201: - m_drawline((long)histleft, (long)LINK->gridy2, (long)across, - (long)LINK->gridy2); + m_drawline((long)histleft, (long)LINK->gridy2, (long)across, (long)LINK->gridy2); gg.actval = (double)(histgridhn->y - LINK->gridy2) / histdivision; calltoolnode(gg.signaltab[gg.actx - 1].np, act_histstr); + if (*gg.actstr == '\0') realunit(LINK->gridstr, gg.actval, 4, "", true); else @@ -11246,8 +11435,7 @@ static void measurecmd(LINK) LINK->gridval2 = valueattime(histgridhn, LINK->gridtime, LINK); historyvaluey(histgridhn, LINK->gridval2, &LINK->gridval, &LINK->valuey); m_drawline((long)LINK->gridx2, 0L, (long)LINK->gridx2, (long)histdown); - m_drawline((long)histleft, (long)LINK->valuey, (long)across, - (long)LINK->valuey); + m_drawline((long)histleft, (long)LINK->valuey, (long)across, (long)LINK->valuey); gg.actval = LINK->gridval; gg.actval2 = LINK->gridval2; gg.actval3 = LINK->gridtime; @@ -11256,21 +11444,22 @@ static void measurecmd(LINK) gg.actx = histgridhn->sig; gg.actgattr = histgridhn->attr; calltoolnode(gg.signaltab[gg.actx - 1].np, act_histstr); + if (*gg.actstr == '\0') strcpy(gg.actstr, realunit(STR1, gg.actval, 4, "", true)); - sprintf(LINK->gridstr, "%s -> %s", - realunit(STR1, LINK->gridtime, 4, "s", true), gg.actstr); + sprintf(LINK->gridstr, "%s -> %s", realunit(STR1, LINK->gridtime, 4, "s", true), gg.actstr); break; case 203: - m_drawline((long)LINK->gridx1, (long)LINK->gridy1, (long)LINK->gridx2, - (long)LINK->gridy2); - if (LINK->gridx1 != LINK->gridx2) { + m_drawline((long)LINK->gridx1, (long)LINK->gridy1, (long)LINK->gridx2, (long)LINK->gridy2); + if (LINK->gridx1 != LINK->gridx2) + { gg.actval2 = (LINK->gridx2 - LINK->gridx1) * histgattr[histsecdiv - 1].UU.r; gg.actval = (LINK->gridy1 - LINK->gridy2) / gg.actval2; gg.actval2 /= histdivision; gg.actval3 = (double)LINK->gridy1 / histdivision; calltoolnode(gg.signaltab[gg.actx - 1].np, act_histstr); + if (*gg.actstr == '\0') realunit(LINK->gridstr, gg.actval, 4, "", true); else @@ -11279,19 +11468,25 @@ static void measurecmd(LINK) } break; } + m_color((long)gg.color.selword); m_colormode((long)m_normal); clipoff(); drawstr2((int)gridpos, LINK->vmenu2, LINK->gridstr); - do { + + do + { passetc(LINK); } while (!gg.t.moving); + m_colormode((long)m_xor); m_color((long)gg.color.selword); clipoff(); drawstr2((int)gridpos, LINK->vmenu2, LINK->gridstr); m_color((long)gg.color.scroll); - switch (histgridwhich * 100 + histgridmode) { + + switch (histgridwhich * 100 + histgridmode) + { case 0: case 100: @@ -11370,25 +11565,31 @@ static void historycommand() V.rflag = true; rmflag = true; hn = gg.hnbase; - while (hn != NULL) { + while (hn != NULL) + { if (hn->y > histdown) hn->y = histaddsignalpos(); hn = hn->next; } - do { - if (V.rflag) { + do + { + if (V.rflag) + { clearscreen(); movinghn = NULL; pass(); gg.showpage = log_page_history; rmflag = true; } - if (rmflag) { + + if (rmflag) + { uerase(0, histdown + 1, across, down); m_color((long)gg.color.menuword); drawstr2(quit1pos, V.vmenu1, "QUIT"); drawstr2(quit2pos, V.vmenu1, "QUIT"); - switch (V.whichmenu) { + switch (V.whichmenu) + { case 0: drawstr2((int)configpos, V.vmenu1, "Configure"); @@ -11417,23 +11618,24 @@ static void historycommand() break; } } - if (V.rflag) { + if (V.rflag) + { drawhistdivisions(histleft, across); drawhistory(&V); } + V.rflag = false; rmflag = false; refrgridmode(&V); ch = '\0'; - do { - if (histgattr[histsweeptype - 1].UU.nv == histsweep_contin && - gg.histactive) { + do + { + if (histgattr[histsweeptype - 1].UU.nv == histsweep_contin && gg.histactive) + { passetc(&V); - flag = (gg.time < histgattr[histfirsttime - 1].UU.r + - histdivsacross * histgattr[histsecdiv - 1].UU.r); + flag = (gg.time < histgattr[histfirsttime - 1].UU.r + histdivsacross * histgattr[histsecdiv - 1].UU.r); if (!flag && histonscreen) { - histgattr[histfirsttime - 1].UU.r = - gg.time - histdivsacross * histgattr[histsecdiv - 1].UU.r * 0.1; + histgattr[histfirsttime - 1].UU.r = gg.time - histdivsacross * histgattr[histsecdiv - 1].UU.r * 0.1; ch = ' '; } histonscreen = flag; @@ -11444,12 +11646,15 @@ static void historycommand() if (pollkbd2()) ch = inkey2(); } while (!(gg.t.dn || ch != '\0')); - if (gg.t.dn) { + + if (gg.t.dn) + { remcursor(); clipoff(); V.gridx1 = gg.t.x; V.gridy1 = gg.t.y; - if (gg.t.y > histdown) { + if (gg.t.y > histdown) + { if (gg.t.x < configpos - 3) ch = '\003'; else if (gg.t.x >= quit2pos - 3) @@ -11457,65 +11662,104 @@ static void historycommand() else if (gg.t.x >= otherpos - 3) { V.whichmenu = (V.whichmenu + 1) & (nummenus - 1); rmflag = true; - } else { - switch (V.whichmenu) { + } + else + { + switch (V.whichmenu) + { case 0: - if (gg.t.x < triggerpos - 3) { + if (gg.t.x < triggerpos - 3) + { confighistmode(&V); V.rflag = true; - } else if (gg.t.x < resetpos - 3) { + } + else if (gg.t.x < resetpos - 3) + { if (gg.histactive) + { gg.histactive = false; - else { + } + else + { gg.histactive = true; histreset = true; } - } else if (gg.t.x < onoffpos - 3) + } + else if (gg.t.x < onoffpos - 3) + { gg.resetflag = true; + } else if (gg.t.x < gridpos - 3) + { gg.pwrflag = !gg.pwrflag; + } else if (gg.t.x < gridwpos - 3) + { nextgridmode(&V); + } else if (gg.t.x < fastpos - 3) + { nextgridwhich(&V); + } else if (gg.t.x < dumppos - 3) + { fastmode(&V); + } else if (gg.t.x < nextpos - 3) + { dumpcmd(&V); + } break; case 1: - if (gg.t.x < yaxispos - 3) { + if (gg.t.x < yaxispos - 3) + { V.xactive = !V.xactive; V.yactive = false; refraxes(&V); - } else if (gg.t.x < exprpos - 3) { + } + else if (gg.t.x < exprpos - 3) + { V.xactive = false; V.yactive = !V.yactive; refraxes(&V); - } else if (gg.t.x < timepos - 3) + } + else if (gg.t.x < timepos - 3) + { getexpr(&V); + } else if (gg.t.x < plotpos - 3) + { setaxis("Time", &V); + } else if (gg.t.x < next2pos - 3) + { plotcmd(&V); + } break; } } - } else if (gg.t.x < histleft - 3) { + } + else if (gg.t.x < histleft - 3) + { hn = gg.hnbase; hn0 = NULL; hn1 = NULL; hn2 = NULL; hn1a = NULL; hn2a = NULL; - while (hn != NULL) { - if (hn->y > gg.t.y - histvscale && hn->y < gg.t.y + histvscale) { - if (histgridhn == hn) { + while (hn != NULL) + { + if (hn->y > gg.t.y - histvscale && hn->y < gg.t.y + histvscale) + { + if (histgridhn == hn) + { hn2 = hn; hn2a = hn0; - } else { + } + else + { hn1 = hn; hn1a = hn0; } @@ -11523,18 +11767,26 @@ static void historycommand() hn0 = hn; hn = hn->next; } - if (hn2 != NULL) { + + if (hn2 != NULL) + { hn = hn2; hn0 = hn2a; - } else { + } + else + { hn = hn1; hn0 = hn1a; } - if (hn != NULL) { - switch (V.whichmenu) { + + if (hn != NULL) + { + switch (V.whichmenu) + { case 0: - if (justtap()) { + if (justtap()) + { gg.actnode = gg.signaltab[hn->sig - 1].np; gg.acty = hn->sig; gg.acttool = gg.actnode->simtype; @@ -11545,10 +11797,13 @@ static void historycommand() gg.acttool->hlbl, gg.signaltab[hn->sig - 1].name, TEMP, TEMP5, TEMP6, &V.stamp); V.rflag = true; - } else { + } + else + { movinghn = hn; drawsigname(hn, 2, &V); - do { + do + { hn->y = gg.t.y; flag = (gg.t.y > 0 && gg.t.y < histdown + 3); alignsigname(&hn->y); @@ -11556,13 +11811,16 @@ static void historycommand() gg.t.y = histdown; if (flag) drawsigname(hn, 3, &V); - do { + do + { passetc(&V); } while (gg.t.depressed && gg.t.y == gg.t0.y); if (flag) drawsigname(hn, 3, &V); } while (gg.t.depressed); - if (!flag) { + + if (!flag) + { if (gg.traceflag) fprintf(tracefile, "Delete trace %ld\n", (long)hn); if (hn == histgridhn) { @@ -11587,16 +11845,23 @@ static void historycommand() break; } } - } else { - switch (V.whichmenu) { + } + else + { + switch (V.whichmenu) + { case 0: - if (justtap()) { + if (justtap()) + { hn = findtrace(V.gridx1, V.gridy1, &V); if (hn != NULL) setgridwhich(hn, &V); - } else + } + else + { measurecmd(&V); + } break; case 1: @@ -11606,41 +11871,53 @@ static void historycommand() break; } } - } else if (ch == 251 || ch == 250 || ch == ' ') { - /* p2c: log.text, line 16367: Note: Character >= 128 encountered [281] */ - /* p2c: log.text, line 16367: Note: Character >= 128 encountered [281] */ + } else if (ch == 251 || ch == 250 || ch == ' ') + { V.rflag = true; - } else if (ch == '<') { - do { + } + else if (ch == '<') + { + do + { histgattr[histsecdiv - 1].UU.r *= 2; t = timers_sysclock() + knobwait; - do { + do + { } while (!(timers_sysclock() > t || pollkbd2())); + if (testkey2() == '<') ch = inkey2(); else V.rflag = true; } while (!V.rflag); - } else if (ch == '>') { - do { + } + else if (ch == '>') + { + do + { histgattr[histsecdiv - 1].UU.r /= 2; t = timers_sysclock() + knobwait; - do { + do + { } while (!(timers_sysclock() > t || pollkbd2())); if (testkey2() == '>') ch = inkey2(); else V.rflag = true; } while (!V.rflag); - } else if (ch < 32 && ((1L << ch) & 0x10000100L) != 0) { + } + else if (ch < 32 && ((1L << ch) & 0x10000100L) != 0) + { scrollpos = 0; - gg.actval = -histgattr[histfirsttime - 1].UU.r / - histgattr[histsecdiv - 1].UU.r; + gg.actval = -histgattr[histfirsttime - 1].UU.r / histgattr[histsecdiv - 1].UU.r; + if (gg.actval < -histdivsacross) scrollmin = -across * 2; else scrollmin = (long)floor(gg.actval * histdivision + 0.5); - do { + + do + { if (ch == '\b') scrollpos -= hscrollspd * 5; if (ch == '\034') @@ -11650,51 +11927,58 @@ static void historycommand() m_colormode((long)m_xor); m_color((long)gg.color.scroll); if (scrollpos > 0) - m_drawline(scrollpos + histleft - 1L, 0L, scrollpos + histleft - 1L, - (long)histdown); - m_drawline(scrollpos + across + 1L, 0L, scrollpos + across + 1L, - (long)histdown); + m_drawline(scrollpos + histleft - 1L, 0L, scrollpos + histleft - 1L, (long)histdown); + m_drawline(scrollpos + across + 1L, 0L, scrollpos + across + 1L, (long)histdown); m_colormode((long)m_normal); t = timers_sysclock() + knobwait; - do { + do + { } while (!(timers_sysclock() > t || pollkbd2())); TEMP7 = testkey2(); + if ((uchar)TEMP7 < 32 && ((1L << TEMP7) & 0x10000100L) != 0) ch = inkey2(); else ch = ' '; + m_colormode((long)m_xor); m_color((long)gg.color.scroll); if (scrollpos > 0) - m_drawline(scrollpos + histleft - 1L, 0L, scrollpos + histleft - 1L, - (long)histdown); - m_drawline(scrollpos + across + 1L, 0L, scrollpos + across + 1L, - (long)histdown); + m_drawline(scrollpos + histleft - 1L, 0L, scrollpos + histleft - 1L, (long)histdown); + m_drawline(scrollpos + across + 1L, 0L, scrollpos + across + 1L, (long)histdown); m_colormode((long)m_normal); - } while (ch < 32 && ((1L << ch) & 0x10000100L) != 0 && - abs(scrollpos) <= across - histleft - 10); + } while (ch < 32 && ((1L << ch) & 0x10000100L) != 0 && abs(scrollpos) <= across - histleft - 10); + if (scrollpos == scrollmin) newhistfirsttime = 0.0; else newhistfirsttime = histgattr[histfirsttime - 1].UU.r + (double)scrollpos / histdivision * histgattr[histsecdiv - 1].UU.r; - if (histgattr[histfirsttime - 1].UU.r != newhistfirsttime) { + + if (histgattr[histfirsttime - 1].UU.r != newhistfirsttime) + { histgattr[histfirsttime - 1].UU.r = newhistfirsttime; histgattr[histfirsttime - 1].changed = true; V.rflag = true; } histonscreen = false; - } else if (ch == '!') { + } + else if (ch == '!') + { doshellescape(""); V.rflag = true; - } else if (ch > ' ') { - switch (V.whichmenu) { + } + else if (ch > ' ') + { + switch (V.whichmenu) + { case 0: y = histaddsignalpos(); *name = '\0'; keyflag = true; - do { + do + { strcat(name, "_"); remcursor(); clipoff(); @@ -11702,9 +11986,11 @@ static void historycommand() m_color((long)gg.color.signal); drawstr2(0, y - 4, name); m_colormode((long)m_normal); - while (!gg.t.dn && !keyflag) { + while (!gg.t.dn && !keyflag) + { passetc(&V); - if (pollkbd2()) { + if (pollkbd2()) + { ch = inkey2(); keyflag = true; } @@ -11715,7 +12001,8 @@ static void historycommand() drawstr2(0, y - 4, name); m_colormode((long)m_normal); name[strlen(name) - 1] = '\0'; - if (keyflag) { + if (keyflag) + { keyflag = false; if (ch > ' ' || (ch == ' ' && *name != '\0')) sprintf(name + strlen(name), "%c", ch); @@ -11724,21 +12011,25 @@ static void historycommand() } } while (!((ch < 32 && ((1L << ch) & 0x2008) != 0) || gg.t.dn)); sprintf(STR2, "%c", ch); + if (!strcmp(STR2, EXEC)) *name = '\0'; else strcpy(name, strrtrim(strcpy(STR3, name))); + remcursor(); clipoff(); i = getsignal(0, name); - if (i != 0) { + if (i != 0) + { histaddsignal(&hn, i, y); V.rflag = true; } break; case 1: - if (V.xactive || V.yactive) { + if (V.xactive || V.yactive) + { ungetkey2(realkey); getexpr(&V); } @@ -11779,32 +12070,30 @@ struct LOC_savepage { short numhw, maxunat; } ; -static short countnode(n, LINK) - log_nrec *n; - struct LOC_savepage *LINK; +static short countnode(log_nrec *n, struct LOC_savepage *LINK) { short i; log_nrec *n1; i = 1; n1 = LINK->firstnode; - while (n1 != n && n1 != NULL) { + while (n1 != n && n1 != NULL) + { i++; n1 = (log_nrec *)n1->temp; } return i; } -static short counthw(hw, LINK) - log_hwrec *hw; - struct LOC_savepage *LINK; +static short counthw(log_hwrec *hw, struct LOC_savepage *LINK) { short i; log_hwrec *hw1; i = 1; hw1 = LINK->firsthwire; - while (hw1 != hw && hw1 != NULL) { + while (hw1 != hw && hw1 != NULL) + { i++; hw1 = (log_hwrec *)hw1->temp; } @@ -11813,32 +12102,30 @@ static short counthw(hw, LINK) return i; } -static short countvw(vw, LINK) - log_vwrec *vw; - struct LOC_savepage *LINK; +static short countvw(log_vwrec *vw, struct LOC_savepage *LINK) { short i; log_vwrec *vw1; i = 1; vw1 = LINK->firstvwire; - while (vw1 != vw && vw1 != NULL) { + while (vw1 != vw && vw1 != NULL) + { i++; vw1 = (log_vwrec *)vw1->temp; } + if (vw1 == NULL) printf("\007Unable to find vwire %ld\n", (long)vw); return (i + LINK->numhw); } -static int eqattr(ka, ga, LINK) - log_kattrrec *ka; - log_gattrrec *ga; - struct LOC_savepage *LINK; +static int eqattr(log_kattrrec *ka, log_gattrrec *ga, struct LOC_savepage *LINK) { int Result; - switch (ka->dtype) { + switch (ka->dtype) + { case 'R': case 'U': @@ -11870,76 +12157,74 @@ static int eqattr(ka, ga, LINK) return Result; } -static na_strlist_t *attrname(i, lbl, LINK) - short i; - na_strlist_t *lbl; - struct LOC_savepage *LINK; +static na_strlist_t *attrname(short i, na_strlist_t *lbl, struct LOC_savepage *LINK) { na_strlist_t *l1; l1 = lbl; while (l1 != NULL && l1->kind != '\001') l1 = l1->next; + if (l1 == NULL) return l1; l1 = (na_strlist_t *)l1->value; + while (l1 != NULL && (long)l1->value != i) l1 = l1->next; + return l1; } -static short countattrs(gattr, numattrs, kattr, lbl, LINK) - log_gattrrec *gattr; - short numattrs; - log_kattrrec *kattr; - na_strlist_t *lbl; - struct LOC_savepage *LINK; +static short countattrs(log_gattrrec *gattr, short numattrs, log_kattrrec *kattr, na_strlist_t *lbl, struct LOC_savepage *LINK) { short i, j; j = 0; - for (i = 1; i <= numattrs; i++) { + for (i = 1; i <= numattrs; i++) + { if (!eqattr(&kattr[i - 1], &gattr[i - 1], LINK) && attrname(i, lbl, LINK) == NULL) j = i; } LINK->maxunat = j; - for (i = j; i < numattrs; i++) { + for (i = j; i < numattrs; i++) + { if (!eqattr(&kattr[i], &gattr[i], LINK)) j++; } return j; } -static void writeattrs(f, gattr, numattrs, kattr, lbl, LINK) - FILE **f; - log_gattrrec *gattr; - short numattrs; - log_kattrrec *kattr; - na_strlist_t *lbl; - struct LOC_savepage *LINK; +static void writeattrs(FILE **f, log_gattrrec *gattr, short numattrs, log_kattrrec *kattr, na_strlist_t *lbl, struct LOC_savepage *LINK) { short num, i; /*reads maxunat from last call to countattrs*/ na_strlist_t *l1; char STR2[81]; num = countattrs(gattr, numattrs, kattr, lbl, LINK); - for (i = 1; i <= numattrs; i++) { - if (i <= LINK->maxunat || !eqattr(&kattr[i - 1], &gattr[i - 1], LINK)) { + for (i = 1; i <= numattrs; i++) + { + if (i <= LINK->maxunat || !eqattr(&kattr[i - 1], &gattr[i - 1], LINK)) + { l1 = attrname(i, lbl, LINK); if (l1 != NULL) + { fprintf(*f, "[%s] ", l1->s); + } if (gattr[i - 1].blnk) + { fprintf(*f, "X\n"); - else { + } + else + { putc(kattr[i - 1].dtype, *f); - switch (kattr[i - 1].dtype) { + switch (kattr[i - 1].dtype) + { case 'R': case 'U': case 'F': - fprintf(*f, "%s\n", - realstr(STR2, gattr[i - 1].UU.r, kattr[i - 1].prec)); + fprintf(*f, "%s\n", realstr(STR2, gattr[i - 1].UU.r, kattr[i - 1].prec)); break; case 'I': @@ -11969,9 +12254,7 @@ static void writeattrs(f, gattr, numattrs, kattr, lbl, LINK) } -static void savepage(pgnum, filename_) - short pgnum; - char *filename_; +static void savepage(short pgnum, char *filename_) { struct LOC_savepage V; char filename[256]; @@ -11994,12 +12277,15 @@ static void savepage(pgnum, filename_) strcpy(filename, filename_); f = NULL; newci_fixfname(filename, "lgf", ""); - if (*filename != '\0' && pageempty(pgnum) && access(filename, F_OK) == 0) { + if (*filename != '\0' && pageempty(pgnum) && access(filename, F_OK) == 0) + { sprintf(STR2, "File %s not overwritten with empty page!", filename); message(STR2); *filename = '\0'; } - if (*filename != '\0') { + + if (*filename != '\0') + { TRY(try24); strcpy(buf, filename); newci_forcefname(buf, "lfo", ""); @@ -12020,33 +12306,43 @@ static void savepage(pgnum, filename_) else */ fprintf(f, "f s\n"); n1 = gg.nbase; - while (n1 != NULL) { + while (n1 != NULL) + { n1->flag = false; n1 = n1->next; } + hw = gg.hwbase[pgnum - 1]; - while (hw != NULL) { + while (hw != NULL) + { hw->node->flag = true; hw = hw->next; } + vw = gg.vwbase[pgnum - 1]; - while (vw != NULL) { + while (vw != NULL) + { vw->node->flag = true; vw = vw->next; } + g = gg.gbase[pgnum - 1]; - while (g != NULL) { + while (g != NULL) + { FORLIM = g->kind->numpins; for (i = 0; i < FORLIM; i++) g->pin[i]->flag = true; g = g->next; } + numnodes = 0; V.firstnode = NULL; lastnode = NULL; n1 = gg.nbase; - while (n1 != NULL) { - if (n1->flag) { + while (n1 != NULL) + { + if (n1->flag) + { numnodes++; /* n1^.temp.p := firstnode; firstnode := n1; */ @@ -12061,13 +12357,12 @@ firstnode := n1; */ } fprintf(f, "n %d\n", numnodes); n1 = V.firstnode; - while (n1 != NULL) { + while (n1 != NULL) + { fprintf(f, "%d ", n1->simtype->simtype); - fprintf(f, "%d\n", - countattrs(n1->attr, n1->simtype->nnumattrs, n1->simtype->nattr, + fprintf(f, "%d\n", countattrs(n1->attr, n1->simtype->nnumattrs, n1->simtype->nattr, n1->simtype->nlbl, &V)); - writeattrs(&f, n1->attr, n1->simtype->nnumattrs, n1->simtype->nattr, - n1->simtype->nlbl, &V); + writeattrs(&f, n1->attr, n1->simtype->nnumattrs, n1->simtype->nattr, n1->simtype->nlbl, &V); gg.actfile = &f; gg.actflag = false; calltoolnode(n1, act_writenode); @@ -12081,22 +12376,24 @@ firstnode := n1; */ gg.signaltab[i].f = false; g = gg.gbase[pgnum - 1]; - while (g != NULL) { - if (g->sig > 0 && g->sig <= gg.lastsignal && - gg.signaltab[g->sig -1].np != NULL && + while (g != NULL) + { + if (g->sig > 0 && g->sig <= gg.lastsignal && gg.signaltab[g->sig -1].np != NULL && gg.signaltab[g->sig -1].np->flag) gg.signaltab[g->sig -1].f = true; g = g->next; } count = 0; - for (i = 0; i < FORLIM; i++) { + for (i = 0; i < FORLIM; i++) + { if (gg.signaltab[i].f) count++; } fprintf(f, "s %d\n", count); - for (i = 0; i < FORLIM; i++) { + for (i = 0; i < FORLIM; i++) + { if (gg.signaltab[i].f) fprintf(f, "%d %s\n", countnode(gg.signaltab[i].np, &V), gg.signaltab[i].name); @@ -12104,7 +12401,8 @@ firstnode := n1; */ V.numhw = 0; hw = gg.hwbase[pgnum - 1]; V.firsthwire = NULL; - while (hw != NULL) { + while (hw != NULL) + { V.numhw++; hw->temp = (void *)V.firsthwire; V.firsthwire = hw; @@ -12113,7 +12411,8 @@ firstnode := n1; */ numvw = 0; vw = gg.vwbase[pgnum - 1]; V.firstvwire = NULL; - while (vw != NULL) { + while (vw != NULL) + { numvw++; vw->temp = (void *)V.firstvwire; V.firstvwire = vw; @@ -12121,14 +12420,16 @@ firstnode := n1; */ } fprintf(f, "w %d\n", V.numhw + numvw); hw = V.firsthwire; - while (hw != NULL) { + while (hw != NULL) + { fprintf(f, "%d %d %d %d %d %s\n", hw->x1, hw->y, hw->x2, hw->y, countnode(hw->node, &V), colorname(STR1, hw->wcolr)); hw = (log_hwrec *)hw->temp; } vw = V.firstvwire; - while (vw != NULL) { + while (vw != NULL) + { fprintf(f, "%d %d %d %d %d %s\n", vw->x, vw->y1, vw->x, vw->y2, countnode(vw->node, &V), colorname(STR1, vw->wcolr)); @@ -12137,7 +12438,8 @@ firstnode := n1; */ count = 0; s = gg.sbase[pgnum - 1]; firstsolder = NULL; - while (s != NULL) { + while (s != NULL) + { count++; s->temp = (void *)firstsolder; firstsolder = s; @@ -12145,7 +12447,8 @@ firstnode := n1; */ } fprintf(f, "p %d\n", count); s = firstsolder; - while (s != NULL) { + while (s != NULL) + { fprintf(f, "%d %d", s->x, s->y); if (s->hwire != NULL) fprintf(f, " %d", counthw(s->hwire, &V)); @@ -12161,7 +12464,8 @@ firstnode := n1; */ count = 0; l = gg.lbase[pgnum - 1]; firstlabel = NULL; - while (l != NULL) { + while (l != NULL) + { count++; l->temp = (void *)firstlabel; firstlabel = l; @@ -12169,18 +12473,18 @@ firstnode := n1; */ } fprintf(f, "l %d\n", count); l = firstlabel; - while (l != NULL) { + while (l != NULL) + { fprintf(f, "%d %d %ld %s\n", l->x, l->y, m_strwidth(logfont_lfont, l->name) / log_scale0, l->name); l = (log_lrec *)l->temp; } - /* p2c: log.text, line 16829: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ count = 0; b = gg.bbase[pgnum - 1]; firstbox = NULL; - while (b != NULL) { + while (b != NULL) + { count++; b->temp = (void *)firstbox; firstbox = b; @@ -12188,35 +12492,40 @@ firstnode := n1; */ } fprintf(f, "b %d\n", count); b = firstbox; - while (b != NULL) { + while (b != NULL) + { fprintf(f, "%d %d %d %d\n", b->x1, b->y1, b->x2, b->y2); b = (log_brec *)b->temp; } count = 0; g = gg.gbase[pgnum - 1]; - while (g != NULL) { + while (g != NULL) + { count++; g = g->next; } fprintf(f, "g %d\n", count); g = gg.gbase[pgnum - 1]; - while (g != NULL) { + while (g != NULL) + { k = g->kind; fprintf(f, "%s\n", k->name); i = 0; - if (g->sig != 0) { + if (g->sig != 0) + { FORLIM = g->sig; - for (j = 0; j < FORLIM; j++) { + for (j = 0; j < FORLIM; j++) + { if (gg.signaltab[j].f) i++; } } fprintf(f, "%d %d %d ", g->x, g->y, g->rot); fprintf(f, "%d %ld %d ", g->gc, (long)g->vars, i); - fprintf(f, "%d\n", - countattrs(g->attr, k->numattrs, k->attr, k->lbl, &V)); + fprintf(f, "%d\n", countattrs(g->attr, k->numattrs, k->attr, k->lbl, &V)); FORLIM = k->numpins; - for (i = 1; i <= FORLIM; i++) { + for (i = 1; i <= FORLIM; i++) + { if (i != 1) putc(' ', f); fprintf(f, "%d", countnode(g->pin[i - 1], &V)); @@ -12231,14 +12540,13 @@ firstnode := n1; */ } fprintf(f, "h %d\n", hncount); hn = gg.hnbase; - while (hn != NULL) { + while (hn != NULL) + { n1 = gg.signaltab[hn->sig - 1].np; fprintf(f, "%d ", hn->y); - fprintf(f, "%d", countattrs(hn->attr, n1->simtype->hnumattrs, - n1->simtype->hattr, n1->simtype->hlbl, &V)); + fprintf(f, "%d", countattrs(hn->attr, n1->simtype->hnumattrs, n1->simtype->hattr, n1->simtype->hlbl, &V)); fprintf(f, " %s\n", gg.signaltab[hn->sig - 1].name); - writeattrs(&f, hn->attr, n1->simtype->hnumattrs, n1->simtype->hattr, - n1->simtype->hlbl, &V); + writeattrs(&f, hn->attr, n1->simtype->hnumattrs, n1->simtype->hattr, n1->simtype->hlbl, &V); hn = hn->next; } fprintf(f, ".\n"); @@ -12255,10 +12563,7 @@ firstnode := n1; */ } - - -static void emergencysave(pgnum) - short pgnum; +static void emergencysave(short pgnum) { char filename[256]; @@ -12278,9 +12583,7 @@ static void emergencysave(pgnum) } -void safesavepage(pgnum, fn) - short pgnum; - char *fn; +void safesavepage(short pgnum, char *fn) { long i, j; @@ -12300,6 +12603,7 @@ void safesavepage(pgnum, fn) if (Debugging || debugprint || gg.traceflag) printf("%ld/%ld/%ld ", i, j, EXCP_LINE); printf("Unable to save file %s\n", fn); + char *fn; enderror(); ENDTRY(try26); } @@ -12314,22 +12618,31 @@ static void savecommand() char STR2[256]; garbagecoll(); - if (*gg.funcarg == '\0') { + if (*gg.funcarg == '\0') + { FORLIM = gg.numpages; - for (pgnum = 1; pgnum <= FORLIM; pgnum++) { - if (!pagechanged(pgnum)) { + for (pgnum = 1; pgnum <= FORLIM; pgnum++) + { + if (!pagechanged(pgnum)) + { sprintf(STR2, "No changes to page %d", pgnum); message(STR2); - } else if (curfilename[pgnum - 1] == NULL) { + } + else if (curfilename[pgnum - 1] == NULL) + { sprintf(STR2, "Page %d: no file name!", pgnum); message(STR2); - } else { + } + else + { sprintf(STR1, "Saving page %d", pgnum); message(STR1); safesavepage(pgnum, curfilename[pgnum - 1]); } } - } else if (!strcmp(gg.funcarg, "*")) { + } + else if (!strcmp(gg.funcarg, "*")) + { beginbottom(); printf("File name to save: "); if (curfilename[gg.curpage - 1] != NULL) @@ -12340,8 +12653,11 @@ static void savecommand() endbottom(); if (*filename != '\0') safesavepage((int)gg.curpage, filename); - } else + } + else + { safesavepage((int)gg.curpage, gg.funcarg); + } clearfunc(); } @@ -12384,9 +12700,7 @@ static void namecommand() } -static void loadlog30(f, ver) - FILE **f; - short ver; +static void loadlog30(FILE **f, short ver) { short i, j, x, y, x1, y1, x2, y2; char nam[81]; @@ -12401,7 +12715,8 @@ static void loadlog30(f, ver) getc(*f); if (ch == '\n') ch = ' '; - switch (ch) { + switch (ch) + { case 'V': case 'v': @@ -12417,56 +12732,81 @@ static void loadlog30(f, ver) getc(*f); setvlsimode(vlsi); j = gg.color.wire[0]; - if (vlsi) { + if (vlsi) + { fscanf(*f, "%hd%hd%hd%hd%hd%*[^\n]", &x1, &x2, &y, &i, &j); getc(*f); - } else { + } + else + { fscanf(*f, "%hd%hd%hd%hd%*[^\n]", &x1, &x2, &y, &i); getc(*f); } - while (x1 != -9999) { + + while (x1 != -9999) + { addhwire(x1, x2, y, log_wcol_normal); - if (vlsi) { + if (vlsi) + { fscanf(*f, "%hd%hd%hd%hd%hd%*[^\n]", &x1, &x2, &y, &i, &j); getc(*f); - } else { + } + else + { fscanf(*f, "%hd%hd%hd%hd%*[^\n]", &x1, &x2, &y, &i); getc(*f); } } - if (vlsi) { + + if (vlsi) + { fscanf(*f, "%hd%hd%hd%hd%hd%*[^\n]", &x, &y1, &y2, &i, &j); getc(*f); - } else { + } + else + { fscanf(*f, "%hd%hd%hd%hd%*[^\n]", &x, &y1, &y2, &i); getc(*f); } - while (x != -9999) { + + while (x != -9999) + { addvwire(x, y1, y2, log_wcol_normal); - if (vlsi) { + if (vlsi) + { fscanf(*f, "%hd%hd%hd%hd%hd%*[^\n]", &x, &y1, &y2, &i, &j); getc(*f); - } else { + } + else + { fscanf(*f, "%hd%hd%hd%hd%*[^\n]", &x, &y1, &y2, &i); getc(*f); } } fscanf(*f, "%hd%hd%hd%hd%*[^\n]", &x, &y, &i, &j); getc(*f); - while (x != -9999) { + while (x != -9999) + { closerwire(x, y); - if (gg.nearhw != NULL && gg.nearvw != NULL) { - if (trycombinenodes(&gg.nearvw->node, &gg.nearhw->node)) { + if (gg.nearhw != NULL && gg.nearvw != NULL) + { + if (trycombinenodes(&gg.nearvw->node, &gg.nearhw->node)) + { clipon(); addsolder(x, y, gg.nearhw, NULL, gg.nearvw, NULL); clipoff(); - } else + } + else + { frysolder(x, y); + } } fscanf(*f, "%hd%hd%hd%hd%*[^\n]", &x, &y, &i, &j); getc(*f); } - if (ver >= 3) { + + if (ver >= 3) + { fscanf(*f, "%hd%hd%hd%c", &x, &y, &i, &ch); if (ch == '\n') ch = ' '; @@ -12474,7 +12814,9 @@ static void loadlog30(f, ver) TEMP = (char *)strchr(nam, '\n'); if (TEMP != NULL) *TEMP = 0; - } else { + } + else + { fscanf(*f, "%hd%hd%c", &x, &y, &ch); if (ch == '\n') ch = ' '; @@ -12483,15 +12825,16 @@ static void loadlog30(f, ver) if (TEMP != NULL) *TEMP = 0; } - while (x != -9999) { + + while (x != -9999) + { newlabel(&l); l->x = x; l->y = y; strcpy(l->name, nam); l->w = m_strwidth(logfont_lfont, l->name) / log_scale0; - /* p2c: log.text, line 17118: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ - if (ver >= 3) { + if (ver >= 3) + { fscanf(*f, "%hd%hd%hd%c", &x, &y, &i, &ch); if (ch == '\n') ch = ' '; @@ -12499,7 +12842,9 @@ static void loadlog30(f, ver) TEMP = (char *)strchr(nam, '\n'); if (TEMP != NULL) *TEMP = 0; - } else { + } + else + { fscanf(*f, "%hd%hd%c", &x, &y, &ch); if (ch == '\n') ch = ' '; @@ -12513,7 +12858,8 @@ static void loadlog30(f, ver) } fscanf(*f, "%hd%hd%hd%hd%*[^\n]", &x, &y, &x1, &y1); getc(*f); - while (x != -9999) { + while (x != -9999) + { newbox(&b); b->x1 = x; b->y1 = y; @@ -12523,28 +12869,38 @@ static void loadlog30(f, ver) getc(*f); } fscanf(*f, "%hd%hd%hd%hd%hd%hd%hd%c", &i, &x, &y, &y1, &x1, &y2, &x2, &ch); + if (ch == '\n') ch = ' '; + fgets(nam, 81, *f); TEMP = (char *)strchr(nam, '\n'); if (TEMP != NULL) *TEMP = 0; - while (i != -9999) { - if ((unsigned)(i & 127) < 32 && ((1L << (i & 127)) & 0x1800) != 0) { + + while (i != -9999) + { + if ((unsigned)(i & 127) < 32 && ((1L << (i & 127)) & 0x1800) != 0) + { if (i == 11) j = readlibrary("TO"); else j = readlibrary("FROM"); addgate1(x, y, j + i / 128 * 128); gg.neargate->sig = getsignal(0, nam); - } else { + } + else + { j = readlibrary(nam); addgate1(x, y, j + i / 128 * 128); } - for (i = 1; i <= y2 + x2; i++) { /*ignore all pins, attributes!*/ + + for (i = 1; i <= y2 + x2; i++) + { /*ignore all pins, attributes!*/ fscanf(*f, "%*[^\n]"); getc(*f); } + fscanf(*f, "%hd%hd%hd%hd%hd%hd%hd%c", &i, &x, &y, &y1, &x1, &y2, &x2, &ch); if (ch == '\n') ch = ' '; @@ -12557,13 +12913,7 @@ static void loadlog30(f, ver) } -static void readattrs(f, gattr, numattrs, kattr, lbl, count) - FILE **f; - log_gattrrec **gattr; - short numattrs; - log_kattrrec *kattr; - na_strlist_t *lbl; - short count; +static void readattrs(FILE **f, log_gattrrec **gattr, short numattrs, log_kattrrec *kattr, na_strelist_t *lbl, short count) { short j, jj; char ch; @@ -12573,45 +12923,65 @@ static void readattrs(f, gattr, numattrs, kattr, lbl, count) l1 = lbl; while (l1 != NULL && l1->kind != '\001') l1 = l1->next; + if (l1 != NULL) names = (na_strlist_t *)l1->value; else names = NULL; - for (j = 1; j <= count; j++) { + + for (j = 1; j <= count; j++) + { ch = getc(*f); if (ch == '\n') ch = ' '; - if (ch == '[') { + + if (ch == '[') + { *buf = '\0'; ch = getc(*f); + if (ch == '\n') ch = ' '; - while (ch != ']' && !P_eoln(*f)) { + + while (ch != ']' && !P_eoln(*f)) + { sprintf(buf + strlen(buf), "%c", ch); ch = getc(*f); if (ch == '\n') ch = ' '; } + jj = -1; - if (!P_eoln(*f)) { + if (!P_eoln(*f)) + { l1 = names; while (l1 != NULL && strcmp(buf, l1->s)) l1 = l1->next; + if (l1 != NULL) jj = (long)l1->value; - do { + + do + { ch = getc(*f); if (ch == '\n') ch = ' '; } while (ch == ' '); } - } else + } + else + { jj = j; - if (jj >= 1 && jj <= numattrs) { + } + + if (jj >= 1 && jj <= numattrs) + { ch = toupper(ch); - if (ch == 'X') { + if (ch == 'X') + { (*gattr)[jj - 1].blnk = true; - switch (kattr[jj - 1].dtype) { + switch (kattr[jj - 1].dtype) + { case 'C': *(*gattr)[jj - 1].UU.c = '\0'; @@ -12621,9 +12991,12 @@ static void readattrs(f, gattr, numattrs, kattr, lbl, count) strchange(&(*gattr)[jj - 1].UU.sp, ""); break; } - } else { + } + else + { (*gattr)[jj - 1].blnk = false; - switch (kattr[jj - 1].dtype) { + switch (kattr[jj - 1].dtype) + { case 'R': case 'U': @@ -12639,7 +13012,8 @@ static void readattrs(f, gattr, numattrs, kattr, lbl, count) break; case 'C': - if (ch == 'A' || ch == 'C') { + if (ch == 'A' || ch == 'C') + { *buf = '\0'; fscanf(*f, "%[^\n]", buf); if (strlen(buf) <= kattr[jj - 1].prec) @@ -12648,7 +13022,8 @@ static void readattrs(f, gattr, numattrs, kattr, lbl, count) break; case 'A': - if (ch == 'A' || ch == 'C') { + if (ch == 'A' || ch == 'C') + { *buf = '\0'; fscanf(*f, "%[^\n]", buf); strchange(&(*gattr)[jj - 1].UU.sp, buf); @@ -12656,7 +13031,8 @@ static void readattrs(f, gattr, numattrs, kattr, lbl, count) break; case 'B': - if (ch == 'B') { + if (ch == 'B') + { ch = getc(*f); if (ch == '\n') ch = ' '; @@ -12665,7 +13041,8 @@ static void readattrs(f, gattr, numattrs, kattr, lbl, count) break; case 'V': - if (ch == 'V') { + if (ch == 'V') + { fscanf(*f, "%hd", &(*gattr)[jj - 1].UU.nv); if ((*gattr)[jj - 1].UU.nv >= kattr[jj - 1].UU.U86.nv) (*gattr)[jj - 1].UU.nv = 0; @@ -12706,9 +13083,7 @@ struct LOC_loadpage { log_nrec **np; } ; -static void loadfail(msg, LINK) - char *msg; - struct LOC_loadpage *LINK; +static void loadfail(char *msg, struct LOC_loadpage *LINK) { if (LINK->f) fclose(LINK->f); @@ -12720,7 +13095,7 @@ static void loadfail(msg, LINK) _Escape(1); } -static log_nrec *countnode_(i, LINK) +static log_nrec *countnode_(short i, struct LOAC_loadpage *LINK) short i; struct LOC_loadpage *LINK; { @@ -12744,10 +13119,7 @@ struct LOC_initialize { } ; -static int tryfindfile(name, path, LINK) - char *name; - char *path; - struct LOC_initialize *LINK; +static int tryfindfile(char *name, char *path, struct LOC_initialize *LINK) { int Result; char fname[256]; @@ -12756,9 +13128,7 @@ static int tryfindfile(name, path, LINK) f = NULL; Result = false; - if (*name != '\0' && - (*path == '\0' || (name[0] != '*' && name[0] != '/' && name[0] != '%' && - name[0] != '~'))) + if (*name != '\0' && (*path == '\0' || (name[0] != '*' && name[0] != '/' && name[0] != '%' && name[0] != '~'))) { TRY(try31); if (name[0] == '~') @@ -12793,9 +13163,7 @@ static int tryfindfile(name, path, LINK) return Result; } -static int locatefile(name, LINK) - char *name; - struct LOC_initialize *LINK; +static int locatefile(char *name, struct LOC_initialize *LINK) { char path[256]; @@ -12806,10 +13174,7 @@ static int locatefile(name, LINK) } - -static void loadpage(filename_, reason_) - char *filename_; - char *reason_; +static void loadpage(char *filename_, char *reason_) { struct LOC_loadpage V; char filename[256]; @@ -12838,7 +13203,8 @@ static void loadpage(filename_, reason_) V.f = NULL; V.ip = NULL; *V.reason = '\0'; - if (*filename != '\0') { + if (*filename != '\0') + { newci_fixfname(filename, "lgf", ""); #ifdef LOAD_SEARCH locatefile(filename, NULL); @@ -12854,54 +13220,71 @@ static void loadpage(filename_, reason_) gg.actx = gg.curpage; calltools(act_clear); hw = gg.hwbase[gg.curpage - 1]; - while (hw != NULL) { + while (hw != NULL) + { gg.hwbase[gg.curpage - 1] = hw->next; stamp(&hw->node->simtype->netstamp); Free(hw); hw = gg.hwbase[gg.curpage - 1]; } + vw = gg.vwbase[gg.curpage - 1]; - while (vw != NULL) { + while (vw != NULL) + { gg.vwbase[gg.curpage - 1] = vw->next; stamp(&vw->node->simtype->netstamp); Free(vw); vw = gg.vwbase[gg.curpage - 1]; } + s = gg.sbase[gg.curpage - 1]; - while (s != NULL) { + while (s != NULL) + { gg.sbase[gg.curpage - 1] = s->next; Free(s); s = gg.sbase[gg.curpage - 1]; } + g = gg.gbase[gg.curpage - 1]; - while (g != NULL) { + while (g != NULL) + { gg.gbase[gg.curpage - 1] = g->next; stamp(&g->kind->simtype->netstamp); disposegate(&g); g = gg.gbase[gg.curpage - 1]; } + l = gg.lbase[gg.curpage - 1]; if (l != NULL) stamp(&gg.labelstamp); - while (l != NULL) { + + while (l != NULL) + { gg.lbase[gg.curpage - 1] = l->next; Free(l); l = gg.lbase[gg.curpage - 1]; } + b = gg.bbase[gg.curpage - 1]; if (b != NULL) stamp(&gg.boxstamp); - while (b != NULL) { + + while (b != NULL) + { gg.bbase[gg.curpage - 1] = b->next; Free(b); b = gg.bbase[gg.curpage - 1]; } + garbagecoll(); stamp(&gg.loadstamp); stamp(&gg.pagestamp[gg.curpage - 1]); if (ver < 5) + { loadlog30(&V.f, ver); - else { + } + else + { cnbase = NULL; fscanf(V.f, "%*[^\n]"); getc(V.f); @@ -12915,7 +13298,9 @@ static void loadpage(filename_, reason_) ch2 = ' '; if (tolower(ch) != 'f' || ch1 != ' ') loadfail("Bad format line", &V); - if (tolower(ch2) != 's') { + + if (tolower(ch2) != 's') + { sprintf(STR2, "Bad format name: %c", ch2); loadfail(STR2, &V); } @@ -12932,7 +13317,8 @@ static void loadpage(filename_, reason_) while (n != NULL && n->next != NULL) n = n->next; FORLIM = V.numnodes; - for (i = 0; i < FORLIM; i++) { + for (i = 0; i < FORLIM; i++) + { fscanf(V.f, "%hd%hd%*[^\n]", &j, &x1); getc(V.f); n1 = n; @@ -12943,13 +13329,13 @@ static void loadpage(filename_, reason_) else n1->next = n; n->next = NULL; - readattrs(&V.f, &n->attr, n->simtype->nnumattrs, n->simtype->nattr, - n->simtype->nlbl, x1); + readattrs(&V.f, &n->attr, n->simtype->nnumattrs, n->simtype->nattr, n->simtype->nlbl, x1); V.np[i] = n; gg.actfile = &V.f; calltoolnode(n, act_readnode); stamp(&n->simtype->netstamp); - while (!P_eoln(V.f) && !P_eof(V.f)) { + while (!P_eoln(V.f) && !P_eof(V.f)) + { fscanf(V.f, "%*[^\n]"); getc(V.f); } @@ -12965,7 +13351,8 @@ static void loadpage(filename_, reason_) if (tolower(ch) != 's') loadfail("No signal-count line", &V); V.ip = (long *) Malloc(count * sizeof(long)); - for (i = 0; i < count; i++) { + for (i = 0; i < count; i++) + { fscanf(V.f, "%hd%c", &j, &ch); if (ch == '\n') ch = ' '; @@ -12988,7 +13375,8 @@ static void loadpage(filename_, reason_) loadfail("No wire-count line", &V); numwires = count; wp = (wirerec *)Malloc(numwires * sizeof(wirerec)); - for (i = 0; i < numwires; i++) { + for (i = 0; i < numwires; i++) + { fscanf(V.f, "%hd%hd%hd%hd%hd%c%c%*[^\n]", &x1, &y1, &x2, &y2, &j, &ch, &ch1); getc(V.f); @@ -12996,7 +13384,8 @@ static void loadpage(filename_, reason_) ch = ' '; if (ch1 == '\n') ch1 = ' '; - switch (ch1) { + switch (ch1) + { case 'U': x = log_wcol_normal; @@ -13023,8 +13412,10 @@ static void loadpage(filename_, reason_) loadfail(STR3, &V); break; } + n = countnode_(j, &V); - if (y1 == y2) { + if (y1 == y2) + { newhw(&hw); hw->x1 = x1; hw->x2 = x2; @@ -13033,7 +13424,9 @@ static void loadpage(filename_, reason_) hw->wcolr = x; wp[i].horiz = true; wp[i].UU.hw = hw; - } else if (x1 == x2) { + } + else if (x1 == x2) + { newvw(&vw); vw->x = x1; vw->y1 = y1; @@ -13042,28 +13435,37 @@ static void loadpage(filename_, reason_) vw->wcolr = x; wp[i].horiz = false; wp[i].UU.vw = vw; - } else + } + else + { loadfail("Wire is not horizontal or vertical", &V); + } } fscanf(V.f, "%c%hd%*[^\n]", &ch, &count); getc(V.f); if (ch == '\n') ch = ' '; + if (tolower(ch) != 'p') loadfail("No solder-count line", &V); - for (i = 1; i <= count; i++) { + + for (i = 1; i <= count; i++) + { fscanf(V.f, "%hd%hd", &x, &y); newsolder(&s); s->x = x; s->y = y; - while (!P_eoln(V.f)) { + while (!P_eoln(V.f)) + { fscanf(V.f, "%hd", &j); if (wp[j - 1].horiz) { if (s->hwire == NULL) s->hwire = wp[j - 1].UU.hw; else s->hwire2 = wp[j - 1].UU.hw; - } else { + } + else + { if (s->vwire == NULL) s->vwire = wp[j - 1].UU.vw; else @@ -13081,7 +13483,9 @@ static void loadpage(filename_, reason_) loadfail("No label-count line", &V); if (count > 0) stamp(&gg.labelstamp); - for (i = 1; i <= count; i++) { + + for (i = 1; i <= count; i++) + { fscanf(V.f, "%hd%hd%hd%c", &x, &y, &j, &ch); if (ch == '\n') ch = ' '; @@ -13096,8 +13500,6 @@ static void loadpage(filename_, reason_) l->y = y; strcpy(l->name, labelname); l->w = m_strwidth(logfont_lfont, l->name) / log_scale0; - /* p2c: log.text, line 17510: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ } fscanf(V.f, "%c%hd%*[^\n]", &ch, &count); getc(V.f); @@ -13107,7 +13509,9 @@ static void loadpage(filename_, reason_) loadfail("No box-count line", &V); if (count > 0) stamp(&gg.boxstamp); - for (i = 1; i <= count; i++) { + + for (i = 1; i <= count; i++) + { fscanf(V.f, "%hd%hd%hd%hd%*[^\n]", &x1, &y1, &x2, &y2); getc(V.f); newbox(&b); @@ -13116,6 +13520,7 @@ static void loadpage(filename_, reason_) b->x2 = x2; b->y2 = y2; } + fscanf(V.f, "%c%hd%*[^\n]", &ch, &count); getc(V.f); if (ch == '\n') @@ -13123,13 +13528,15 @@ static void loadpage(filename_, reason_) if (tolower(ch) != 'g') loadfail("No gate-count line", &V); g = NULL; - for (i = 1; i <= count; i++) { + for (i = 1; i <= count; i++) + { fgets(tempname, 256, V.f); TEMP = (char *)strchr(tempname, '\n'); if (TEMP != NULL) *TEMP = 0; j = readlibrary(tempname); - if (j != 0) { + if (j != 0) + { fscanf(V.f, "%hd%hd%hd%hd%ld%hd%hd%*[^\n]", &x, &y, &x1, &y1, &ii, &x2, &y2); getc(V.f); @@ -13151,19 +13558,20 @@ static void loadpage(filename_, reason_) g->sig = V.ip[x2 - 1]; stamp(&g->kind->simtype->netstamp); j = 1; - while (j <= g->kind->numpins && !P_eoln(V.f)) { + while (j <= g->kind->numpins && !P_eoln(V.f)) + { fscanf(V.f, "%hd", &k); g->pin[j - 1] = countnode_(k, &V); j++; } - while (j <= g->kind->numpins) { + while (j <= g->kind->numpins) + { newnode(&g->pin[j - 1], g->kind->pin[j - 1].s); j++; } fscanf(V.f, "%*[^\n]"); getc(V.f); - readattrs(&V.f, &g->attr, g->kind->numattrs, g->kind->attr, - g->kind->lbl, y2); + readattrs(&V.f, &g->attr, g->kind->numattrs, g->kind->attr, g->kind->lbl, y2); initpinpos(g); gg.actflag = true; calltoolgate(g, act_connectgate); @@ -13173,7 +13581,8 @@ static void loadpage(filename_, reason_) gg.actflag = true; calltoolgate(g, act_readgate); } - while (!P_eoln(V.f) && !P_eof(V.f)) { + while (!P_eoln(V.f) && !P_eof(V.f)) + { fscanf(V.f, "%*[^\n]"); getc(V.f); } @@ -13187,11 +13596,13 @@ static void loadpage(filename_, reason_) ch = getc(V.f); if (ch == '\n') ch = ' '; - if (tolower(ch) == 'h') { + if (tolower(ch) == 'h') + { fscanf(V.f, "%hd%*[^\n]", &count); getc(V.f); histdelsignals(); - for (i = 1; i <= count; i++) { + for (i = 1; i <= count; i++) + { fscanf(V.f, "%hd%hd%c", &y, &x1, &ch); if (ch == '\n') ch = ' '; @@ -13261,12 +13672,15 @@ static void loadcommand() cat = NULL; for (i = 0; i <= dircol; i++) dirs[i] = NULL; - if (!strcmp(gg.funcarg, "*")) { + if (!strcmp(gg.funcarg, "*")) + { beginbottom(); printf("Name of file to load: "); readlnpass(filename, 0); endbottom(); - } else if (*gg.funcarg == '\0') { + } + else if (*gg.funcarg == '\0') + { clearshowalpha(); if (cat != NULL) Free(cat); @@ -13276,27 +13690,34 @@ static void loadcommand() printf("Name of file to load: "); *filename = '\0'; ch = '\015'; - do { - do { + do + { + do + { x = (gg.t.ax - 2) / 15; y = gg.t.ay - 2; /* x := (gg.t.x-22) div 90; y := (gg.t.y-46) div 15; if gg.t.x < 22 then x := 0; if gg.t.y < 46 then y := 0; */ - if (x < 0 || (unsigned)y > dirmax || x > dircol || dirs[x] == NULL || - *dirs[x][y] == '\0') + if (x < 0 || (unsigned)y > dirmax || x > dircol || dirs[x] == NULL || *dirs[x][y] == '\0') + { x = -1; - else { + } + else + { nk_gotoxy(x * 15 + 2, y + 2); printf("%c%s%c", chrinverse, dirs[x][y], chrplain); } + if (gg.t.near_ && gg.t.inalpha) nk_gotoxy(gg.t.ax, gg.t.ay); else nk_gotoxy((int)(strlen(filename) + 24), txdown - 2); + nc_cursor_on(); - do { + do + { pass(); pen(); x1 = (gg.t.ax - 2) / 15; @@ -13305,45 +13726,56 @@ if gg.t.y < 46 then y := 0; */ y1 := (gg.t.y-46) div 15; if gg.t.x < 22 then x1 := 0; if gg.t.y < 46 then y1 := 0; */ - if (y1 < 0 || x1 < 0 || y1 > dirmax || x1 > dircol || - dirs[x1] == NULL || *dirs[x1][y1] == '\0') + if (y1 < 0 || x1 < 0 || y1 > dirmax || x1 > dircol || dirs[x1] == NULL || *dirs[x1][y1] == '\0') x1 = -1; } while (!(pollkbd2() || gg.t.dn || x != x1 || y != y1) && gg.t.near_); nc_cursor_off(); remcursor(); - if (x != -1) { + if (x != -1) + { nk_gotoxy(x * 15 + 2, y + 2); fputs(dirs[x][y], stdout); } } while (!(pollkbd2() || gg.t.dn)); - if (gg.t.dn && x != -1) { + + if (gg.t.dn && x != -1) + { strcpy(filename, dirs[x][y]); nk_gotoxy(24, txdown - 2); printf("%s\t", filename); } + if (gg.t.dn) ch = '\015'; else ch = inkey2(); - if (ch == '\007' && *filename != '\0') { + + if (ch == '\007' && *filename != '\0') + { nk_gotoxy((int)(strlen(filename) + 23), txdown - 2); putchar(' '); filename[strlen(filename) - 1] = '\0'; - } else if (ch >= ' ' && ch <= '~' && strlen(filename) < 255) { + } + else if (ch >= ' ' && ch <= '~' && strlen(filename) < 255) + { nk_gotoxy((int)(strlen(filename) + 24), txdown - 2); putchar(ch); strcat(filename, " "); filename[strlen(filename) - 1] = ch; } } while ((uchar)ch >= 32 || ((1L << ch) & 0x2008) == 0); - for (i = 0; i <= dircol; i++) { + + for (i = 0; i <= dircol; i++) + { if (dirs[i] != NULL) Free(dirs[i]); } + sprintf(STR3, "%c", ch); if (!strcmp(STR3, EXEC)) *filename = '\0'; clearalpha(); + if (m_autoraise) { } @@ -13351,9 +13783,14 @@ if gg.t.y < 46 then y1 := 0; */ { m_graphics_on(); } - } else + } + else + { strcpy(filename, gg.funcarg); - if (*filename != '\0') { + } + + if (*filename != '\0') + { beginbottom(); TRY(try27); printf("Loading file %s\n", filename); @@ -13397,9 +13834,7 @@ struct LOC_readlgf { long *ip; } ; -static void loadfail_(msg, LINK) - char *msg; - struct LOC_readlgf *LINK; +static void loadfail_(char *msg, struct LOC_readlgf *LINK) { if (*LINK->f) fclose(*LINK->f); @@ -13412,9 +13847,7 @@ static void loadfail_(msg, LINK) } -static void readlgf(f, reason_) - FILE **f; - char *reason_; +static void readlgf(FILE **f, char *reason_) { struct LOC_readlgf V; char buf[256]; @@ -13436,12 +13869,15 @@ static void readlgf(f, reason_) *TEMP = 0; if (strcmp(buf, "f s")) loadfail_("Not an LGF file", &V); - do { - while (P_eoln(*V.f) && !P_eof(*V.f)) { + do + { + while (P_eoln(*V.f) && !P_eof(*V.f)) + { fscanf(*V.f, "%*[^\n]"); getc(*V.f); } - do { + do + { if (P_eof(*V.f)) ch = '.'; else { @@ -13450,7 +13886,9 @@ static void readlgf(f, reason_) ch = ' '; } } while (ch == ' '); - switch (tolower(ch)) { + + switch (tolower(ch)) + { case '#': /*comment*/ fscanf(*V.f, "%*[^\n]"); @@ -13463,11 +13901,13 @@ static void readlgf(f, reason_) for (j = 1; j <= i; j++) { fscanf(*V.f, "%ld%ld%*[^\n]", &m, &n); getc(*V.f); /*simtype, num attrs*/ - for (m = 1; m <= n; m++) { /*skip attributes*/ + for (m = 1; m <= n; m++) + { /*skip attributes*/ fscanf(*V.f, "%*[^\n]"); getc(*V.f); } - while (!P_eoln(*V.f) && !P_eof(*V.f)) { /*skip simtype info*/ + while (!P_eoln(*V.f) && !P_eof(*V.f)) + { /*skip simtype info*/ fscanf(*V.f, "%*[^\n]"); getc(*V.f); } @@ -13478,7 +13918,8 @@ static void readlgf(f, reason_) fscanf(*V.f, "%ld%*[^\n]", &i); getc(*V.f); V.ip = (long *)Malloc(i * sizeof(long) ); - for (j = 0; j < i; j++) { + for (j = 0; j < i; j++) + { fscanf(*V.f, "%ld%c", &n, &ch); if (ch == '\n') ch = ' '; @@ -13495,7 +13936,8 @@ static void readlgf(f, reason_) case 'w': /*wires*/ fscanf(*V.f, "%ld%*[^\n]", &i); getc(*V.f); - for (j = 1; j <= i; j++) { + for (j = 1; j <= i; j++) + { fscanf(*V.f, "%hd%hd%hd%hd%*[^\n]", &x1, &y1, &x2, &y2); getc(*V.f); /*skip node & color info*/ if (x1 != x2) @@ -13508,7 +13950,8 @@ static void readlgf(f, reason_) case 'p': /*solder*/ fscanf(*V.f, "%ld%*[^\n]", &i); getc(*V.f); - for (j = 1; j <= i; j++) { + for (j = 1; j <= i; j++) + { fscanf(*V.f, "%hd%hd%*[^\n]", &x1, &y1); getc(*V.f); /*skip over wire numbers*/ solderat(x1, y1); @@ -13518,7 +13961,8 @@ static void readlgf(f, reason_) case 'l': /*labels*/ fscanf(*V.f, "%ld%*[^\n]", &i); getc(*V.f); - for (j = 1; j <= i; j++) { + for (j = 1; j <= i; j++) + { fscanf(*V.f, "%hd%hd%ld%c", &x1, &y1, &k, &ch); if (ch == '\n') ch = ' '; @@ -13535,7 +13979,8 @@ static void readlgf(f, reason_) case 'b': /*boxes*/ fscanf(*V.f, "%ld%*[^\n]", &i); getc(*V.f); - for (j = 1; j <= i; j++) { + for (j = 1; j <= i; j++) + { fscanf(*V.f, "%hd%hd%hd%hd%*[^\n]", &x1, &y1, &x2, &y2); getc(*V.f); addboxat(x1, y1, x2, y2); @@ -13545,18 +13990,19 @@ static void readlgf(f, reason_) case 'g': /*gates*/ fscanf(*V.f, "%ld%*[^\n]", &i); getc(*V.f); - for (j = 1; j <= i; j++) { + for (j = 1; j <= i; j++) + { fgets(buf, 256, *V.f); TEMP = (char *)strchr(buf, '\n'); if (TEMP != NULL) *TEMP = 0; k = readlibrary(buf); if (k != 0) { - fscanf(*V.f, "%hd%hd%hd%hd%ld%ld%ld%*[^\n]", &x1, &y1, &x2, &y2, &ii, - &m, &n); + fscanf(*V.f, "%hd%hd%hd%hd%ld%ld%ld%*[^\n]", &x1, &y1, &x2, &y2, &ii, &m, &n); getc(*V.f); addgate1(x1, y1, (int)(k + x2 * log_kindoffset)); - if (gg.neargate != NULL) { + if (gg.neargate != NULL) + { g = gg.neargate; g->gc = y2; g->vars = (na_long)ii; @@ -13571,10 +14017,12 @@ static void readlgf(f, reason_) calltoolgate(g, act_readgate); } } - while (!P_eoln(*V.f) && !P_eof(*V.f)) { + while (!P_eoln(*V.f) && !P_eof(*V.f)) + { fscanf(*V.f, "%*[^\n]"); getc(*V.f); } + if (P_eof(*V.f)) loadfail_("End-of-file while reading gates", &V); fscanf(*V.f, "%*[^\n]"); @@ -13586,7 +14034,8 @@ static void readlgf(f, reason_) fscanf(*V.f, "%ld%*[^\n]", &i); getc(*V.f); histdelsignals(); - for (j = 1; j <= i; j++) { + for (j = 1; j <= i; j++) + { fscanf(*V.f, "%hd%hd%c", &y1, &x1, &ch); if (ch == '\n') ch = ' '; @@ -13599,8 +14048,7 @@ static void readlgf(f, reason_) loadfail_(NULL, &V); n1 = gg.signaltab[x2 - 1].np; histaddsignal(&hn, x2, y1); - readattrs(V.f, &hn->attr, n1->simtype->hnumattrs, n1->simtype->hattr, - n1->simtype->hlbl, x1); + readattrs(V.f, &hn->attr, n1->simtype->hnumattrs, n1->simtype->hattr, n1->simtype->hlbl, x1); } break; @@ -13624,19 +14072,14 @@ struct LOC_readpage { char *reason; } ; -static void loadfail__(msg, LINK) - char *msg; - struct LOC_readpage *LINK; +static void loadfail__(char *msg, struct LOC_radpage *LINK) { strcpy(LINK->reason, msg); _Escape(1); } - -static void readpage(filename_, reason_) - char *filename_; - char *reason_; +static void readpage(char *filename_, char *reason_) { struct LOC_readpage V; char filename[256]; @@ -13678,20 +14121,25 @@ static void readpage(filename_, reason_) } - static void readcommand() { char filename[256], reason[256]; long i, j; - if (*gg.funcarg == '\0' || !strcmp(gg.funcarg, "*")) { + if (*gg.funcarg == '\0' || !strcmp(gg.funcarg, "*")) + { beginbottom(); printf("Name of file to read: "); readlnpass(filename, 0); endbottom(); - } else + } + else + { strcpy(filename, gg.funcarg); - if (*filename != '\0') { + } + + if (*filename != '\0') + { beginbottom(); printf("Reading file %s\n", filename); deleverything(); @@ -13707,6 +14155,7 @@ static void readcommand() beginerror(); if (Debugging || debugprint || gg.traceflag) printf("%ld/%ld/%ld ", i, j, EXCP_LINE); + if (i == -10 && (unsigned long)j < 32 && ((1L << j) & 0x600) != 0) printf("Can't find file \"%s\"\n", filename); else if (i == -20) @@ -13722,7 +14171,6 @@ static void readcommand() } - static void singlestep() { gg.singlestepcount = getint(gg.funcarg, 1L); @@ -13737,7 +14185,8 @@ static void getgatecmd() short i; char name[9]; - do { + do + { getword(gg.funcarg, name); if (*name != '\0') i = readlibrary(name); @@ -13751,7 +14200,8 @@ static void makegatecmd() short i; char name[9]; - do { + do + { getword(gg.funcarg, name); if (*name != '\0') { i = readlibrary(name); @@ -13772,9 +14222,7 @@ struct LOC_toolcommand { int refrflag, wasselected; } ; -static void describe(i, LINK) - long i; - struct LOC_toolcommand *LINK; +static void describe(long i, LOC_toolcommand *LINK) { if (LINK->ta[i] == NULL) return; @@ -13787,8 +14235,7 @@ static void describe(i, LINK) printf("%c\n", chrgreen); } -static long which(LINK) - struct LOC_toolcommand *LINK; +static long which(struct LOC_toolcommand *LINK) { if (gg.t.near_ && gg.t.ay >= 1 && gg.t.ay <= maxtools) return (gg.t.ay); @@ -13796,17 +14243,17 @@ static long which(LINK) return -1; } -static void selecttool(name, LINK) - char *name; - struct LOC_toolcommand *LINK; +static void selecttool(char *name, struct LOC_toolcommand *LINK) { log_tool *tp; tp = findtool(name); - if (!tp->ready) { + if (!tp->ready) + { warning(); return; } + calltool(tp, act_select); if (!tp->keep) closetool(tp); @@ -13824,15 +14271,21 @@ static void toolcommand() V.wasselected = false; if (*gg.funcarg != '\0') + { selecttool(gg.funcarg, &V); - else { - do { + } + else + { + do + { for (i = 0; i <= maxtools; i++) V.ta[i] = NULL; numtools = 0; tp = gg.toolbase; - while (tp != NULL) { - if (*tp->comment != '\0' && numtools < maxtools) { + while (tp != NULL) + { + if (*tp->comment != '\0' && numtools < maxtools) + { numtools++; V.ta[numtools + 1] = tp; } @@ -13844,32 +14297,44 @@ static void toolcommand() describe(i, &V); exitflag = false; V.refrflag = false; - do { - do { + do + { + do + { j = which(&V); - if (j >= 0) { + if (j >= 0) + { putchar(chrinverse); describe(j, &V); putchar(chrplain); } + if (gg.t.near_ && gg.t.inalpha) nk_gotoxy(gg.t.ax, gg.t.ay); else noblink(); - do { + + do + { pass(); pen(); } while (!(which(&V) != j || gg.t.dn || pollkbd2())); + if (j >= 0) describe(j, &V); - } while (!(gg.t.dn || pollkbd2())); + } + while (!(gg.t.dn || pollkbd2())); nk_gotoxy(0, txdown); + if (pollkbd2()) ch = toupper(inkey2()); else ch = '\0'; - if (gg.t.dn) { - switch (j) { + + if (gg.t.dn) + { + switch (j) + { case -1: ch = '\003'; @@ -13882,19 +14347,26 @@ static void toolcommand() break; } } - if (ch >= 'A' && ch <= 'X') { + + if (ch >= 'A' && ch <= 'X') + { tp = V.ta[ch - 64]; - if (tp != NULL) { + if (tp != NULL) + { selecttool(tp->name, &V); exitflag = true; } - } else if (ch == '\003' || ch == '\015' || ch == ' ') + } + else if (ch == '\003' || ch == '\015' || ch == ' ') + { exitflag = true; + } } while (!(V.refrflag || exitflag)); } while (!exitflag); } clearalpha(); - if (V.wasselected) { + if (V.wasselected) + { m_graphics_on(); refresh(); } @@ -13907,15 +14379,15 @@ static void toolcommand() #define whichmin (-2) -static log_tool *counttool(i) - long i; +static log_tool *counttool(long i) { log_tool *tp; tp = gg.toolbase; while (tp->nostatus) tp = tp->next; - while (i > 1) { + while (i > 1) + { tp = tp->next; if (!tp->nostatus) i--; @@ -13942,7 +14414,8 @@ static void status_log() char * months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - if (gg.actflag) { + if (gg.actflag) + { sysdate(&date); printf(" Date %2d-%s-%02d Time\n", date.day, months[date.month - 1], date.year); @@ -13965,31 +14438,42 @@ static void status_log() status_oldtstep = -1.0; status_oldmem = -1; } - if (labs(timers_sysclock() - gg.actx) > 50) { + + if (labs(timers_sysclock() - gg.actx) > 50) + { nk_gotoxy(25, 4); systime(&time); printf("%2d:%02d:%02ld", time.hour, time.minute, time.centisecond / 100L); gg.actx = timers_sysclock(); } - if (memavail() != status_oldmem) { + + if (memavail() != status_oldmem) + { nk_gotoxy(23, 5); printf("%ld", memavail()); status_oldmem = memavail(); } - if (gg.time != status_oldtime) { + + if (gg.time != status_oldtime) + { nk_gotoxy(23, 7); printf("%s\t", realunit(STR3, gg.time, 4, "sec", false)); status_oldtime = gg.time; } - if (gg.prevtimestep != status_oldtstep) { + + if (gg.prevtimestep != status_oldtstep) + { nk_gotoxy(23, 8); printf("%s\t", realunit(STR3, gg.prevtimestep, 4, "sec", false)); status_oldtstep = gg.prevtimestep; } + if (gg.simstate == gg.oldsimstate && gg.simstatetool == gg.oldsimstatetool) return; nk_gotoxy(23, 9); - switch (gg.simstate) { + + switch (gg.simstate) + { case simst_off: printf("Off\t"); @@ -14029,103 +14513,127 @@ static void status_mem() if (!gg.actflag) return; + printf(" gates wires labels boxes changed filename\n"); - for (i = 0; i <= 8; i++) { + for (i = 0; i <= 8; i++) + { if (i + 1 == gg.curpage) putchar(chryellow); printf("Page %ld -- ", i + 1); - if (i + 1 <= gg.numpages) { + if (i + 1 <= gg.numpages) + { g = gg.gbase[i]; j = 0; - while (g != NULL) { + while (g != NULL) + { j++; g = g->next; } printf("%4ld", j); hw = gg.hwbase[i]; j = 0; - while (hw != NULL) { + while (hw != NULL) + { j++; hw = hw->next; } vw = gg.vwbase[i]; - while (vw != NULL) { + while (vw != NULL) + { j++; vw = vw->next; } printf("%7ld", j); l = gg.lbase[i]; j = 0; - while (l != NULL) { + while (l != NULL) + { j++; l = l->next; } printf("%7ld", j); b = gg.bbase[i]; j = 0; - while (b != NULL) { + while (b != NULL) + { j++; b = b->next; } printf("%7ld ", j); + if (pagechanged((int)(i + 1))) printf("Yes "); else printf("No "); + if (curfilename[i] != NULL) fputs(curfilename[i], stdout); - } else + } + else + { printf("Empty."); + } printf("%c\n", chrgreen); } printf("\nPaste -- "); - if (copybuf.valid) { + if (copybuf.valid) + { g = copybuf.gcopy; j = 0; - while (g != NULL) { + while (g != NULL) + { j++; g = g->next; } printf("%4ld", j); hw = copybuf.hwcopy; j = 0; - while (hw != NULL) { + while (hw != NULL) + { j++; hw = hw->next; } vw = copybuf.vwcopy; - while (vw != NULL) { + while (vw != NULL) + { j++; vw = vw->next; } printf("%7ld", j); l = copybuf.lcopy; j = 0; - while (l != NULL) { + while (l != NULL) + { j++; l = l->next; } printf("%7ld", j); b = copybuf.bcopy; j = 0; - while (b != NULL) { + while (b != NULL) + { j++; b = b->next; } printf("%7ld\n", j); - } else + } + else + { printf("Empty.\n"); + } putchar('\n'); n = gg.nbase; j = 0; - while (n != NULL) { + while (n != NULL) + { j++; n = n->next; } printf("Total nodes: %12ld\n", j); j = 0; FORLIM = gg.lastsignal; - for (i = 0; i < FORLIM; i++) { + for (i = 0; i < FORLIM; i++) + { if (gg.signaltab[i].np != NULL) j++; } @@ -14165,12 +14673,15 @@ static void status_macro(int v) mp = macrobase; i = 2; n_to_print = P_min(half-n,txdown-4); - do { + do + { j = 4; for (k=0; k < n && mp != NULL; k++) mp = mp->next; - do { - if (mp != NULL) { + do + { + if (mp != NULL) + { nk_gotoxy((int)i, (int)j); ch = mp->key; if (ch == '\007') @@ -14192,7 +14703,9 @@ static void status_macro(int v) } j++; } while (j < txdown && j < n_to_print+4 && mp != NULL); - if (i < 40) { + + if (i < 40) + { for (k = 0, mp = macrobase; mp != NULL && k < half ; k++) mp = mp->next; } @@ -14204,13 +14717,9 @@ static void status_macro(int v) nk_gotoxy((int)2, (int)txdown); printf("[%d of %d]",((n+1)/(n_displayed/2))+1,(n_macros/n_displayed)+1); - /* p2c: log.text, line 18560: Note: Character >= 128 encountered [281] */ - /* p2c: log.text, line 18560: Note: Character >= 128 encountered [281] */ - /* p2c: log.text, line 18562: Note: Character >= 128 encountered [281] */ } -static void statusdisplay(name_) - char *name_; +static void statusdisplay(char *name_) { char name[256]; char ch; @@ -14225,22 +14734,26 @@ static void statusdisplay(name_) clearshowalpha(); whichmax = 0; tp = gg.toolbase; - while (tp != NULL) { + while (tp != NULL) + { if (!tp->nostatus) whichmax++; tp = tp->next; } strupper(name, strcpy(STR2, strltrim(strrtrim(strcpy(STR3, name))))); + if (!strcmp(name, "LOG")) which = -2; else if (!strcmp(name, "MEMORY")) which = -1; else if (!strcmp(name, "MACRO") || !strcmp(name, "KEYBOARD")) which = 0; - else { + else + { tp = gg.toolbase; which = 1; - while (tp != NULL && strcmp(tp->name, name)) { + while (tp != NULL && strcmp(tp->name, name)) + { if (!tp->nostatus) which++; tp = tp->next; @@ -14248,13 +14761,16 @@ static void statusdisplay(name_) if (tp == NULL) which = whichmin; } + exitflag = false; - do { + do + { clearshowalpha(); printf(" LOG V%s Status Display\n\n", log_version); printf("Status: "); - switch (which) { + switch (which) + { case -2: printf("LOG"); @@ -14280,10 +14796,12 @@ static void statusdisplay(name_) refrflag = false; gg.actflag = true; nk_gotoxy(0, 4); - do { + do + { gg.actx = savex; gg.acty = savey; - switch (which) { + switch (which) + { case -2: status_log(); @@ -14318,7 +14836,8 @@ static void statusdisplay(name_) ch = '\003'; if (pollkbd2()) ch = inkey2(); - switch (ch) { + switch (ch) + { case 31: n = -1; refrflag = true; @@ -14331,7 +14850,8 @@ static void statusdisplay(name_) case '+': case '\034': - if (which < whichmax) { + if (which < whichmax) + { which++; refrflag = true; } @@ -14339,7 +14859,8 @@ static void statusdisplay(name_) case '-': case '\b': - if (which > whichmin) { + if (which > whichmin) + { which--; refrflag = true; }