Browse Source

getexpress(), iptr ==> p + 1

pre-master-46
rlar 8 years ago
parent
commit
6da6f6a4fd
  1. 41
      src/frontend/numparam/xpressn.c

41
src/frontend/numparam/xpressn.c

@ -1342,13 +1342,14 @@ getexpress(const char * const s, SPICE_DSTRINGPTR tstr_p, const char **pi)
{ {
const char *ia_ptr; const char *ia_ptr;
const char *ls_ptr; const char *ls_ptr;
const char *iptr = *pi;
const char *p;
(p + 1) = *pi;
int level; int level;
char c, d; char c, d;
nupa_type tpe; nupa_type tpe;
ls_ptr = s + strlen(s); ls_ptr = s + strlen(s);
ia_ptr = iptr + 1;
ia_ptr = (p + 1) + 1;
while ((ia_ptr < ls_ptr) && (ia_ptr[-1] <= ' ')) while ((ia_ptr < ls_ptr) && (ia_ptr[-1] <= ' '))
ia_ptr++; /*white space ? */ ia_ptr++; /*white space ? */
@ -1356,51 +1357,51 @@ getexpress(const char * const s, SPICE_DSTRINGPTR tstr_p, const char **pi)
if (ia_ptr[-1] == '"') { if (ia_ptr[-1] == '"') {
/* string constant */ /* string constant */
ia_ptr++; ia_ptr++;
iptr = ia_ptr;
(p + 1) = ia_ptr;
while ((iptr < ls_ptr) && (iptr[-1] != '"'))
iptr++;
while (((p + 1) < ls_ptr) && ((p + 1)[-1] != '"'))
(p + 1)++;
tpe = NUPA_STRING; tpe = NUPA_STRING;
do do
iptr++;
while ((iptr <= ls_ptr) && (iptr[-1] <= ' '));
(p + 1)++;
while (((p + 1) <= ls_ptr) && ((p + 1)[-1] <= ' '));
} else { } else {
if (ia_ptr[-1] == '{') if (ia_ptr[-1] == '{')
ia_ptr++; ia_ptr++;
iptr = ia_ptr - 1;
(p + 1) = ia_ptr - 1;
do do
{ {
iptr++;
(p + 1)++;
if (iptr > ls_ptr)
if ((p + 1) > ls_ptr)
c = ';'; c = ';';
else else
c = iptr[-1];
c = (p + 1)[-1];
if (c == '(') { if (c == '(') {
/* sub-formula */ /* sub-formula */
level = 1; level = 1;
do do
{ {
iptr++;
(p + 1)++;
if (iptr > ls_ptr)
if ((p + 1) > ls_ptr)
d = '\0'; d = '\0';
else else
d = iptr[-1];
d = (p + 1)[-1];
if (d == '(') if (d == '(')
level++; level++;
else if (d == ')') else if (d == ')')
level--; level--;
} while ((iptr <= ls_ptr) && !((d == ')') && (level <= 0)));
} while (((p + 1) <= ls_ptr) && !((d == ')') && (level <= 0)));
} }
} while (!strchr(",;)}", c)); /* legal separators */ } while (!strchr(",;)}", c)); /* legal separators */
@ -1408,15 +1409,15 @@ getexpress(const char * const s, SPICE_DSTRINGPTR tstr_p, const char **pi)
tpe = NUPA_REAL; tpe = NUPA_REAL;
} }
pscopy(tstr_p, ia_ptr - 1, 0, (int) (iptr - ia_ptr));
pscopy(tstr_p, ia_ptr - 1, 0, (int) (p + 1 - ia_ptr));
if (iptr[-1] == '}')
iptr++;
if ((p + 1)[-1] == '}')
(p + 1)++;
if (tpe == NUPA_STRING) if (tpe == NUPA_STRING)
iptr++; /* beyond quote */
(p + 1)++; /* beyond quote */
*pi = iptr;
*pi = (p + 1);
return tpe; return tpe;
} }

Loading…
Cancel
Save