From 528c50dc464fa23bbfdd200c6ff971ac88ecd700 Mon Sep 17 00:00:00 2001 From: Brian Taylor Date: Mon, 23 May 2022 14:25:08 -0700 Subject: [PATCH] Retain the param: section after removing the optional: section from a Pspice subckt declaration. --- src/frontend/inpcom.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index c386ded9a..3b93546e3 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -8337,7 +8337,7 @@ static struct card *u_instances(struct card *startcard) int udev_ok = 0, udev_not_ok = 0; BOOL create_called = FALSE, repeat_pass = FALSE; BOOL skip_next = FALSE; - char *tmp = NULL, *pos, *new_str = NULL; + char *tmp = NULL, *pos, *posp, *new_str = NULL; card = startcard; while (card) { @@ -8361,11 +8361,25 @@ static struct card *u_instances(struct card *startcard) initialize_udevice(subcktcard->line); create_called = TRUE; } else { + /* Pspice definition of .subckt card: + .SUBCKT [node]* + + [OPTIONAL: < = >*] + + [PARAMS: < = >* ] + + [TEXT: < = >* ] + ... + .ENDS + */ tmp = TMALLOC(char, strlen(cut_line) + 1); (void) memcpy(tmp, cut_line, strlen(cut_line) + 1); pos = strstr(tmp, "optional:"); + posp = strstr(tmp, "params:"); + /* If there is an optional: and a param: then posp > pos */ if (pos) { + /* Remove the optional: section if present */ *pos = '\0'; + if (posp) { + strcat(tmp, posp); + } } new_str = copy(tmp); tfree(tmp);