Move evaluation of statistical functions inside of a B source
to after numparam expansion, thus allow parameters in functions agauss etc. Replace gettok by new gettok_np to ignore characters ( ) , which may be left over after parameter expansion. This fixes bug 593.
This commit is contained in:
parent
905b1eae8c
commit
72cfc681e5
|
|
@ -760,15 +760,6 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
|
||||||
endTime = seconds();
|
endTime = seconds();
|
||||||
loadTime = endTime - startTime;
|
loadTime = endTime - startTime;
|
||||||
startTime = endTime;
|
startTime = endTime;
|
||||||
/*This is for the globel param setting only */
|
|
||||||
/* replace agauss(x,y,z) in each b-line by suitable value, one for all */
|
|
||||||
bool statlocal = cp_getvar("statlocal", CP_BOOL, NULL, 0);
|
|
||||||
if (!statlocal) {
|
|
||||||
static char *statfcn[] = {"agauss", "gauss", "aunif", "unif", "limit"};
|
|
||||||
int ii;
|
|
||||||
for (ii = 0; ii < 5; ii++)
|
|
||||||
eval_agauss(deck, statfcn[ii]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we have large PDK deck, search for scale option and set
|
/* If we have large PDK deck, search for scale option and set
|
||||||
the variable 'scale'*/
|
the variable 'scale'*/
|
||||||
|
|
@ -840,6 +831,15 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* replace agauss(x,y,z) in each b-line by suitable value, one for all */
|
||||||
|
bool statlocal = cp_getvar("statlocal", CP_BOOL, NULL, 0);
|
||||||
|
if (!statlocal) {
|
||||||
|
static char* statfcn[] = { "agauss", "gauss", "aunif", "unif", "limit" };
|
||||||
|
int ii;
|
||||||
|
for (ii = 0; ii < 5; ii++)
|
||||||
|
eval_agauss(deck, statfcn[ii]);
|
||||||
|
}
|
||||||
|
|
||||||
/* Scan the deck again, now also adding .save commands to wl_first */
|
/* Scan the deck again, now also adding .save commands to wl_first */
|
||||||
for (dd = deck->nextcard; dd; dd = dd->nextcard) {
|
for (dd = deck->nextcard; dd; dd = dd->nextcard) {
|
||||||
char* curr_line = dd->line;
|
char* curr_line = dd->line;
|
||||||
|
|
@ -2360,7 +2360,7 @@ eval_agauss(struct card *deck, char *fcn)
|
||||||
double x, y, z, val;
|
double x, y, z, val;
|
||||||
int skip_control = 0;
|
int skip_control = 0;
|
||||||
|
|
||||||
card = deck;
|
card = deck->nextcard; /* skip title line */
|
||||||
for (; card; card = card->nextcard) {
|
for (; card; card = card->nextcard) {
|
||||||
|
|
||||||
char *ap, *curr_line = card->line;
|
char *ap, *curr_line = card->line;
|
||||||
|
|
@ -2384,7 +2384,7 @@ eval_agauss(struct card *deck, char *fcn)
|
||||||
while ((ap = search_identifier(curr_line, fcn, curr_line)) != NULL) {
|
while ((ap = search_identifier(curr_line, fcn, curr_line)) != NULL) {
|
||||||
char *lparen, *begstr, *contstr = NULL, *new_line, *midstr;
|
char *lparen, *begstr, *contstr = NULL, *new_line, *midstr;
|
||||||
char *tmp1str, *tmp2str, *delstr;
|
char *tmp1str, *tmp2str, *delstr;
|
||||||
int nerror;
|
int nerror = 0;
|
||||||
|
|
||||||
begstr = copy_substring(curr_line, ap);
|
begstr = copy_substring(curr_line, ap);
|
||||||
lparen = strchr(ap, '(');
|
lparen = strchr(ap, '(');
|
||||||
|
|
@ -2392,21 +2392,21 @@ eval_agauss(struct card *deck, char *fcn)
|
||||||
if (lparen + 1)
|
if (lparen + 1)
|
||||||
contstr = copy(lparen + 1);
|
contstr = copy(lparen + 1);
|
||||||
tmp1str++; /* skip '(' */
|
tmp1str++; /* skip '(' */
|
||||||
/* find the parameters */
|
/* find the parameters, ignore ( ) , */
|
||||||
delstr = tmp2str = gettok(&tmp1str);
|
delstr = tmp2str = gettok_np(&tmp1str);
|
||||||
x = INPevaluate(&tmp2str, &nerror, 1);
|
x = INPevaluate(&tmp2str, &nerror, 1);
|
||||||
tfree(delstr);
|
tfree(delstr);
|
||||||
delstr = tmp2str = gettok(&tmp1str);
|
delstr = tmp2str = gettok_np(&tmp1str);
|
||||||
y = INPevaluate(&tmp2str, &nerror, 1);
|
y = INPevaluate(&tmp2str, &nerror, 1);
|
||||||
tfree(delstr);
|
tfree(delstr);
|
||||||
if (cieq(fcn, "agauss")) {
|
if (cieq(fcn, "agauss")) {
|
||||||
delstr = tmp2str = gettok(&tmp1str);
|
delstr = tmp2str = gettok_np(&tmp1str);
|
||||||
z = INPevaluate(&tmp2str, &nerror, 1);
|
z = INPevaluate(&tmp2str, &nerror, 1);
|
||||||
tfree(delstr);
|
tfree(delstr);
|
||||||
val = agauss(x, y, z);
|
val = agauss(x, y, z);
|
||||||
}
|
}
|
||||||
else if (cieq(fcn, "gauss")) {
|
else if (cieq(fcn, "gauss")) {
|
||||||
delstr = tmp2str = gettok(&tmp1str);
|
delstr = tmp2str = gettok_np(&tmp1str);
|
||||||
z = INPevaluate(&tmp2str, &nerror, 1);
|
z = INPevaluate(&tmp2str, &nerror, 1);
|
||||||
tfree(delstr);
|
tfree(delstr);
|
||||||
val = gauss(x, y, z);
|
val = gauss(x, y, z);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue