Browse Source

numparm, rewrite some conditional expressions

pre-master-46
rlar 15 years ago
parent
commit
b48b6a3474
  1. 5
      ChangeLog
  2. 2
      src/frontend/numparam/mystring.c
  3. 50
      src/frontend/numparam/xpressn.c

5
ChangeLog

@ -1,3 +1,8 @@
2011-02-19 Robert Larice
* src/frontend/numparam/mystring.c ,
* src/frontend/numparam/xpressn.c :
numparm, rewrite some conditional expressions
2011-02-19 Robert Larice 2011-02-19 Robert Larice
* src/frontend/numparam/mystring.c : * src/frontend/numparam/mystring.c :
silence compiler warnings silence compiler warnings

2
src/frontend/numparam/mystring.c

@ -599,7 +599,7 @@ freadstr (FILE * f, SPICE_DSTRINGPTR dstr_p)
spice_dstring_append( dstr_p, str_load, 1 ) ; spice_dstring_append( dstr_p, str_load, 1 ) ;
} }
} }
while (!(feof (f) || (c == '\n')));
while (!feof (f) && (c != '\n'));
return len ; return len ;

50
src/frontend/numparam/xpressn.c

@ -434,7 +434,7 @@ attrib (tdico *dico_p, NGHASHPTR htable_p, char *t, char op)
entry_p = NULL ; entry_p = NULL ;
} }
if (!(entry_p))
if (!entry_p)
{ {
entry_p = TMALLOC(entry, 1) ; entry_p = TMALLOC(entry, 1) ;
entry_p->symbol = strdup( t ) ; entry_p->symbol = strdup( t ) ;
@ -486,7 +486,7 @@ define (tdico * dico,
} }
entry_p = attrib (dico, htable_p, t, op); entry_p = attrib (dico, htable_p, t, op);
err = 0; err = 0;
if (!(entry_p))
if (!entry_p)
err = message (dico, " Symbol table overflow"); err = message (dico, " Symbol table overflow");
else else
{ {
@ -685,7 +685,7 @@ keyword ( SPICE_DSTRINGPTR keys_p, SPICE_DSTRINGPTR tstr_p)
k++; k++;
ok = (k <= lk) && (t[i - 1] == keys[k - 1]); ok = (k <= lk) && (t[i - 1] == keys[k - 1]);
} }
while (!((!ok) || (i >= lt)));
while (ok && (i < lt));
if (ok) if (ok)
ok = (k == lk) || (keys[k] <= ' '); ok = (k == lk) || (keys[k] <= ' ');
@ -694,7 +694,7 @@ keyword ( SPICE_DSTRINGPTR keys_p, SPICE_DSTRINGPTR tstr_p)
while ((k <= lk) && (keys[k - 1] > ' ')) while ((k <= lk) && (keys[k - 1] > ' '))
k++; k++;
} }
while (!(ok || (k >= lk)));
while (!ok && (k < lk));
if (ok) if (ok)
return j; return j;
@ -727,7 +727,7 @@ fetchid (char *s, SPICE_DSTRINGPTR t, int ls, int i)
bool ok; bool ok;
c = s[i - 1]; c = s[i - 1];
while ((!alfa (c)) && (i < ls))
while (!alfa (c) && (i < ls))
{ {
i++; i++;
c = s[i - 1]; c = s[i - 1];
@ -781,7 +781,7 @@ exists (tdico * d, char *s, int *pi, bool *perror)
ok = (c == '('); ok = (c == '(');
} }
while (!(ok || (c == '\0')));
while (!ok && (c != '\0'));
if (ok) if (ok)
{ {
@ -801,7 +801,7 @@ exists (tdico * d, char *s, int *pi, bool *perror)
ok = (c == ')'); ok = (c == ')');
} }
while (!(ok || (c == '\0')));
while (!ok && (c != '\0'));
} }
if (!ok) if (!ok)
error = message (d, " Defined() syntax"); error = message (d, " Defined() syntax");
@ -1148,7 +1148,7 @@ formula (tdico * dico, char *s, bool *perror)
error = 0; error = 0;
level = 0; level = 0;
while ((i < ls) && (!error))
while ((i < ls) && !error)
{ {
i++; i++;
c = s[i - 1]; c = s[i - 1];
@ -1183,7 +1183,7 @@ formula (tdico * dico, char *s, bool *perror)
arg3 = k; /* kludge for more than 2 args (ternary expression) */ arg3 = k; /* kludge for more than 2 args (ternary expression) */
} /* comma list? */ ; } /* comma list? */ ;
} }
while (!((k > ls) || ((d == ')') && (level <= 0))));
while ((k <= ls) && !((d == ')') && (level <= 0)));
if (k > ls) if (k > ls)
{ {
@ -1392,7 +1392,7 @@ evaluate (tdico * dico, SPICE_DSTRINGPTR qstr_p, char *t, unsigned char mode)
/* string? */ /* string? */
stupcase (t); stupcase (t);
entry_p = entrynb (dico, t); entry_p = entrynb (dico, t);
nolookup = (!(entry_p));
nolookup = !entry_p;
while ((entry_p) && (entry_p->tp == 'P')) while ((entry_p) && (entry_p->tp == 'P'))
{ {
entry_p = entry_p->pointer ; /* follow pointer chain */ entry_p = entry_p->pointer ; /* follow pointer chain */
@ -1429,7 +1429,7 @@ evaluate (tdico * dico, SPICE_DSTRINGPTR qstr_p, char *t, unsigned char mode)
if (!done) if (!done)
cadd (qstr_p, dt); cadd (qstr_p, dt);
} }
while (!(done));
while (!done);
} }
if (!entry_p) if (!entry_p)
@ -1484,7 +1484,7 @@ scanline (tdico * dico, char *s, char *r, bool err)
pscopy (r, s, 1, 7); pscopy (r, s, 1, 7);
i = 7; i = 7;
} }
while ((i < ls) && (!err))
while ((i < ls) && !err)
{ {
i++; i++;
c = s[i - 1]; c = s[i - 1];
@ -1506,7 +1506,7 @@ scanline (tdico * dico, char *s, char *r, bool err)
nnest--; nnest--;
} }
} }
while (!((nnest == 0) || (d == '\0')));
while ((nnest != 0) && (d != '\0'));
if (d == '\0') if (d == '\0')
{ {
err = message (dico, "Closing \"}\" not found."); err = message (dico, "Closing \"}\" not found.");
@ -1563,7 +1563,7 @@ scanline (tdico * dico, char *s, char *r, bool err)
level--; level--;
} }
} }
while (!((k > ls) || ((d == ')') && (level <= 0))));
while ((k <= ls) && !((d == ')') && (level <= 0)));
if (k > ls) if (k > ls)
{ {
err = message (dico, "Closing \")\" not found."); err = message (dico, "Closing \")\" not found.");
@ -1590,7 +1590,7 @@ scanline (tdico * dico, char *s, char *r, bool err)
d = s[k - 1]; d = s[k - 1];
} }
} }
while (!((k > ls) || (d <= ' ')));
while ((k <= ls) && (d > ' '));
pscopy (t, s, i, k - i); pscopy (t, s, i, k - i);
err = evaluate (dico, q, t, 1); err = evaluate (dico, q, t, 1);
i = k - 1; i = k - 1;
@ -1612,13 +1612,13 @@ scanline (tdico * dico, char *s, char *r, bool err)
{ {
i++; i++;
} }
while (!(s[i - 1] > ' '));
while (s[i - 1] <= ' ');
k = i; k = i;
do do
{ {
k++; k++;
} }
while (!((k > ls) || !alfanum (s[k - 1])));
while ((k <= ls) && alfanum (s[k - 1]));
pscopy (q, s, i, k - i); pscopy (q, s, i, k - i);
nd = parsenode (Addr (dico->nodetab), q); nd = parsenode (Addr (dico->nodetab), q);
if (!spice3) if (!spice3)
@ -1772,7 +1772,7 @@ nupa_substitute (tdico * dico, char *s, char *r, bool err)
err = 0; err = 0;
ir = 0; ir = 0;
while ((i < ls) && (!err))
while ((i < ls) && !err)
{ {
i++; i++;
c = s[i - 1]; c = s[i - 1];
@ -1791,7 +1791,7 @@ nupa_substitute (tdico * dico, char *s, char *r, bool err)
else if (d == '}') else if (d == '}')
nnest--; nnest--;
} }
while (!((nnest == 0) || (d == '\0')));
while ((nnest != 0) && (d != '\0'));
if (d == '\0') if (d == '\0')
err = message (dico, "Closing \"}\" not found."); err = message (dico, "Closing \"}\" not found.");
@ -1847,7 +1847,7 @@ nupa_substitute (tdico * dico, char *s, char *r, bool err)
else if (d == ')') else if (d == ')')
level--; level--;
} }
while (!((k > ls) || ((d == ')') && (level <= 0))));
while ((k <= ls) && !((d == ')') && (level <= 0)));
if (k > ls) if (k > ls)
err = message (dico, "Closing \")\" not found."); err = message (dico, "Closing \")\" not found.");
@ -1869,7 +1869,7 @@ nupa_substitute (tdico * dico, char *s, char *r, bool err)
else else
d = s[k - 1]; d = s[k - 1];
} }
while (!((k > ls) || (d <= ' ')));
while ((k <= ls) && (d > ' '));
pscopy (&tstr, s, i-1, k - i); pscopy (&tstr, s, i-1, k - i);
err = evaluate (dico, &qstr, spice_dstring_value(&tstr), 1); err = evaluate (dico, &qstr, spice_dstring_value(&tstr), 1);
@ -1903,7 +1903,7 @@ getword (char *s, SPICE_DSTRINGPTR tstr_p, int after, int *pi)
{ {
i++; i++;
} }
while (!((i >= ls) || alfa (s[i - 1])));
while ((i < ls) && !alfa (s[i - 1]));
spice_dstring_reinit(tstr_p) ; spice_dstring_reinit(tstr_p) ;
@ -1955,7 +1955,7 @@ getexpress (char *s, SPICE_DSTRINGPTR tstr_p, int *pi)
{ {
i++; i++;
} }
while (!((i > ls) || (s[i - 1] > ' ')));
while ((i <= ls) && (s[i - 1] <= ' '));
} }
else else
{ {
@ -1992,7 +1992,7 @@ getexpress (char *s, SPICE_DSTRINGPTR tstr_p, int *pi)
else if (d == ')') else if (d == ')')
level--; level--;
} }
while (!((i > ls) || ((d == ')') && (level <= 0))));
while ((i <= ls) && !((d == ')') && (level <= 0)));
} }
/* buggy? */ if ((c == '/') || (c == '-')) /* buggy? */ if ((c == '/') || (c == '-'))
comment = (s[i] == c); comment = (s[i] == c);
@ -2058,7 +2058,7 @@ nupa_assignment (tdico * dico, char *s, char mode)
i++; i++;
} }
while ((i < ls) && (!error))
while ((i < ls) && !error)
{ {
key = getword (s, &tstr, i, &i); key = getword (s, &tstr, i, &i);
t_p = spice_dstring_value(&tstr) ; t_p = spice_dstring_value(&tstr) ;

Loading…
Cancel
Save