white spaces

This commit is contained in:
Holger Vogt 2018-05-22 20:34:44 +02:00
parent 7b6cd86a62
commit ae81481229
1 changed files with 81 additions and 81 deletions

View File

@ -6930,68 +6930,68 @@ pspice_compat(struct card *oldcard)
* simple hierachy, as nested subcircuits are not allowed in PSPICE */ * simple hierachy, as nested subcircuits are not allowed in PSPICE */
/* first scan: find the vswitch models, transform them and put them into a list */ /* first scan: find the vswitch models, transform them and put them into a list */
for (card = newcard; card; card = card->nextcard) { for (card = newcard; card; card = card->nextcard) {
char *str; char *str;
static struct card *subcktline = NULL; static struct card *subcktline = NULL;
static int nesting = 0; static int nesting = 0;
char *cut_line = card->line; char *cut_line = card->line;
if (ciprefix(".subckt", cut_line)) { if (ciprefix(".subckt", cut_line)) {
subcktline = card; subcktline = card;
nesting++; nesting++;
} }
if (ciprefix(".ends", cut_line)) if (ciprefix(".ends", cut_line))
nesting--; nesting--;
if (ciprefix(".model", card->line) && strstr(card->line, "vswitch")) { if (ciprefix(".model", card->line) && strstr(card->line, "vswitch")) {
char *modpar[4]; char *modpar[4];
char *modname; char *modname;
int i; int i;
card->line = str = inp_remove_ws(card->line); card->line = str = inp_remove_ws(card->line);
str = nexttok(str); /* throw away '.model' */ str = nexttok(str); /* throw away '.model' */
INPgetNetTok(&str, &modname, 0); /* model name */ INPgetNetTok(&str, &modname, 0); /* model name */
if (!ciprefix("vswitch", str)) if (!ciprefix("vswitch", str))
continue; continue;
/* we have to find 4 parameters, identified by '=', separated by spaces */ /* we have to find 4 parameters, identified by '=', separated by spaces */
char *equalptr[4]; char *equalptr[4];
equalptr[0] = strstr(str, "="); equalptr[0] = strstr(str, "=");
if (!equalptr[0]) { if (!equalptr[0]) {
fprintf(stderr, "Error: not enough parameters in vswitch model\n %s\n", card->line); fprintf(stderr, "Error: not enough parameters in vswitch model\n %s\n", card->line);
controlled_exit(1); controlled_exit(1);
} }
for (i = 1; i < 4; i++) { for (i = 1; i < 4; i++) {
equalptr[i] = strstr(equalptr[i - 1] + 1, "="); equalptr[i] = strstr(equalptr[i - 1] + 1, "=");
if (!equalptr[i]) { if (!equalptr[i]) {
fprintf(stderr, "Error: not enough parameters in vswitch model\n %s\n", card->line); fprintf(stderr, "Error: not enough parameters in vswitch model\n %s\n", card->line);
controlled_exit(1); controlled_exit(1);
} }
} }
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
equalptr[i] = skip_back_ws(equalptr[i], str); equalptr[i] = skip_back_ws(equalptr[i], str);
equalptr[i] = skip_back_non_ws(equalptr[i], str); equalptr[i] = skip_back_non_ws(equalptr[i], str);
} }
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
modpar[i] = copy_substring(equalptr[i], equalptr[i + 1] - 1); modpar[i] = copy_substring(equalptr[i], equalptr[i + 1] - 1);
if (strrchr(equalptr[3], ')')) if (strrchr(equalptr[3], ')'))
modpar[3] = copy_substring(equalptr[3], strrchr(equalptr[3], ')')); modpar[3] = copy_substring(equalptr[3], strrchr(equalptr[3], ')'));
else else
/* vswitch defined without parens */ /* vswitch defined without parens */
modpar[3] = copy(equalptr[3]); modpar[3] = copy(equalptr[3]);
tfree(card->line); tfree(card->line);
/* replace VON by cntl_on, VOFF by cntl_off, RON by r_on, and ROFF by r_off */ /* replace VON by cntl_on, VOFF by cntl_off, RON by r_on, and ROFF by r_off */
rep_spar(modpar); rep_spar(modpar);
card->line = tprintf(".model a%s aswitch(%s %s %s %s log=TRUE)", card->line = tprintf(".model a%s aswitch(%s %s %s %s log=TRUE)",
modname, modpar[0], modpar[1], modpar[2], modpar[3]); modname, modpar[0], modpar[1], modpar[2], modpar[3]);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
tfree(modpar[i]); tfree(modpar[i]);
if (nesting > 0) if (nesting > 0)
modelsfound = insert_new_model(modelsfound, modname, subcktline->line); modelsfound = insert_new_model(modelsfound, modname, subcktline->line);
else else
modelsfound = insert_new_model(modelsfound, modname, "top"); modelsfound = insert_new_model(modelsfound, modname, "top");
} }
} }
/* second scan: find the switch instances s calling a vswitch model and transform them */ /* second scan: find the switch instances s calling a vswitch model and transform them */
for (card = newcard; card; card = card->nextcard) { for (card = newcard; card; card = card->nextcard) {
static struct card *subcktline = NULL; static struct card *subcktline = NULL;
static int nesting = 0; static int nesting = 0;
char *cut_line = card->line; char *cut_line = card->line;
@ -7016,27 +7016,27 @@ pspice_compat(struct card *oldcard)
if (ciprefix(".ends", cut_line)) if (ciprefix(".ends", cut_line))
nesting--; nesting--;
if (ciprefix("s", cut_line)) { if (ciprefix("s", cut_line)) {
/* check for the model name */ /* check for the model name */
int i; int i;
char *stoks[6]; char *stoks[6];
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
stoks[i] = gettok(&cut_line); stoks[i] = gettok(&cut_line);
/* rewrite s line and replace it if a model is found */ /* rewrite s line and replace it if a model is found */
if (find_a_model(modelsfound, stoks[5], subcktline->line)) { if (find_a_model(modelsfound, stoks[5], subcktline->line)) {
tfree(card->line); tfree(card->line);
card->line = tprintf("a%s %%vd(%s %s) %%gd(%s %s) a%s", card->line = tprintf("a%s %%vd(%s %s) %%gd(%s %s) a%s",
stoks[0], stoks[3], stoks[4], stoks[1], stoks[2], stoks[5]); stoks[0], stoks[3], stoks[4], stoks[1], stoks[2], stoks[5]);
} }
/* if model is not within same subcircuit, search at top level */ /* if model is not within same subcircuit, search at top level */
else if (find_a_model(modelsfound, stoks[5], "top")) { else if (find_a_model(modelsfound, stoks[5], "top")) {
tfree(card->line); tfree(card->line);
card->line = tprintf("a%s %%vd(%s %s) %%gd(%s %s) a%s", card->line = tprintf("a%s %%vd(%s %s) %%gd(%s %s) a%s",
stoks[0], stoks[3], stoks[4], stoks[1], stoks[2], stoks[5]); stoks[0], stoks[3], stoks[4], stoks[1], stoks[2], stoks[5]);
} }
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
tfree(stoks[i]); tfree(stoks[i]);
} }
} }
del_models(modelsfound); del_models(modelsfound);