Browse Source

getexpress(), cleanup

pre-master-46
rlar 8 years ago
parent
commit
d1b25d59bb
  1. 22
      src/frontend/numparam/xpressn.c

22
src/frontend/numparam/xpressn.c

@ -1348,37 +1348,37 @@ getexpress(const char * const s, SPICE_DSTRINGPTR tstr_p, const char **pi)
nupa_type tpe; nupa_type tpe;
ls_ptr = s + strlen(s); ls_ptr = s + strlen(s);
xia_ptr = (p + 1) + 1 - 1;
xia_ptr = p + 1;
while (((xia_ptr + 1) < ls_ptr) && (*xia_ptr <= ' '))
while ((xia_ptr < ls_ptr - 1) && (*xia_ptr <= ' '))
xia_ptr++; /*white space ? */ xia_ptr++; /*white space ? */
if (*xia_ptr == '"') { if (*xia_ptr == '"') {
/* string constant */ /* string constant */
xia_ptr++; xia_ptr++;
p = (xia_ptr + 1) - 1;
p = xia_ptr;
while (((p + 1) < ls_ptr) && (*p != '"'))
while ((p < ls_ptr - 1) && (*p != '"'))
p++; p++;
tpe = NUPA_STRING; tpe = NUPA_STRING;
do do
p++; p++;
while (((p + 1) <= ls_ptr) && (*p <= ' '));
while ((p <= ls_ptr - 1) && (*p <= ' '));
} else { } else {
if (*xia_ptr == '{') if (*xia_ptr == '{')
xia_ptr++; xia_ptr++;
p = (xia_ptr + 1) - 1 - 1;
p = xia_ptr - 1;
do do
{ {
p++; p++;
if ((p + 1) > ls_ptr)
if (p > ls_ptr - 1)
c = ';'; c = ';';
else else
c = *p; c = *p;
@ -1390,7 +1390,7 @@ getexpress(const char * const s, SPICE_DSTRINGPTR tstr_p, const char **pi)
{ {
p++; p++;
if ((p + 1) > ls_ptr)
if (p > ls_ptr - 1)
d = '\0'; d = '\0';
else else
d = *p; d = *p;
@ -1400,7 +1400,7 @@ getexpress(const char * const s, SPICE_DSTRINGPTR tstr_p, const char **pi)
else if (d == ')') else if (d == ')')
level--; level--;
} while (((p + 1) <= ls_ptr) && !((d == ')') && (level <= 0)));
} while ((p <= ls_ptr - 1) && !((d == ')') && (level <= 0)));
} }
} while (!strchr(",;)}", c)); /* legal separators */ } while (!strchr(",;)}", c)); /* legal separators */
@ -1408,7 +1408,7 @@ getexpress(const char * const s, SPICE_DSTRINGPTR tstr_p, const char **pi)
tpe = NUPA_REAL; tpe = NUPA_REAL;
} }
pscopy(tstr_p, (xia_ptr + 1) - 1, 0, (int) (p + 1 - (xia_ptr + 1)));
pscopy(tstr_p, xia_ptr, 0, (int) (p - xia_ptr));
if (*p == '}') if (*p == '}')
p++; p++;
@ -1416,7 +1416,7 @@ getexpress(const char * const s, SPICE_DSTRINGPTR tstr_p, const char **pi)
if (tpe == NUPA_STRING) if (tpe == NUPA_STRING)
p++; /* beyond quote */ p++; /* beyond quote */
*pi = (p + 1);
*pi = p + 1;
return tpe; return tpe;
} }

Loading…
Cancel
Save