inpcom.c, cleanup
This commit is contained in:
parent
11ed05191f
commit
0dfbbbedce
|
|
@ -157,9 +157,11 @@ static struct library *
|
||||||
find_lib(char *name)
|
find_lib(char *name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < num_libraries; i++)
|
for (i = 0; i < num_libraries; i++)
|
||||||
if (cieq(libraries[i].name, name))
|
if (cieq(libraries[i].name, name))
|
||||||
return & libraries[i];
|
return & libraries[i];
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -168,9 +170,13 @@ static struct line *
|
||||||
find_section_definition(struct line *c, char *name)
|
find_section_definition(struct line *c, char *name)
|
||||||
{
|
{
|
||||||
for (; c; c = c->li_next) {
|
for (; c; c = c->li_next) {
|
||||||
|
|
||||||
char *line = c->li_line;
|
char *line = c->li_line;
|
||||||
|
|
||||||
if (ciprefix(".lib", line)) {
|
if (ciprefix(".lib", line)) {
|
||||||
|
|
||||||
char *s, *t, *y;
|
char *s, *t, *y;
|
||||||
|
|
||||||
s = skip_non_ws(line);
|
s = skip_non_ws(line);
|
||||||
while (isspace(*s) || isquote(*s))
|
while (isspace(*s) || isquote(*s))
|
||||||
s++;
|
s++;
|
||||||
|
|
@ -403,6 +409,7 @@ find_assignment(char *str)
|
||||||
...
|
...
|
||||||
debug printout to debug-out.txt
|
debug printout to debug-out.txt
|
||||||
*-------------------------------------------------------------------------*/
|
*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
struct line *
|
struct line *
|
||||||
inp_readall(FILE *fp, int call_depth, char *dir_name, bool comfile, bool intfile)
|
inp_readall(FILE *fp, int call_depth, char *dir_name, bool comfile, bool intfile)
|
||||||
/* fp: in, pointer to file to be read,
|
/* fp: in, pointer to file to be read,
|
||||||
|
|
@ -839,6 +846,7 @@ inp_readall(FILE *fp, int call_depth, char *dir_name, bool comfile, bool intfile
|
||||||
(int) max_line_length, no_braces, dynmaxline);
|
(int) max_line_length, no_braces, dynmaxline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cc;
|
return cc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -848,6 +856,7 @@ inp_readall(FILE *fp, int call_depth, char *dir_name, bool comfile, bool intfile
|
||||||
if the file isn't in . and it isn't an abs path name.
|
if the file isn't in . and it isn't an abs path name.
|
||||||
For MS Windows: First try the path of the source file.
|
For MS Windows: First try the path of the source file.
|
||||||
*-------------------------------------------------------------------------*/
|
*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
FILE *
|
FILE *
|
||||||
inp_pathopen(char *name, char *mode)
|
inp_pathopen(char *name, char *mode)
|
||||||
{
|
{
|
||||||
|
|
@ -857,6 +866,7 @@ inp_pathopen(char *name, char *mode)
|
||||||
|
|
||||||
#if defined(HAS_WINGUI)
|
#if defined(HAS_WINGUI)
|
||||||
char buf2[BSIZE_SP];
|
char buf2[BSIZE_SP];
|
||||||
|
|
||||||
/* search in the path where the source (input) file has been found,
|
/* search in the path where the source (input) file has been found,
|
||||||
but only if "name" is just a file name */
|
but only if "name" is just a file name */
|
||||||
if (!strchr(name, DIR_TERM) && !strchr(name, DIR_TERM_LINUX) && cp_getvar("sourcefile", CP_STRING, buf2)) {
|
if (!strchr(name, DIR_TERM) && !strchr(name, DIR_TERM_LINUX) && cp_getvar("sourcefile", CP_STRING, buf2)) {
|
||||||
|
|
@ -878,6 +888,7 @@ inp_pathopen(char *name, char *mode)
|
||||||
if ((fp = fopen(buf2, mode)) != NULL)
|
if ((fp = fopen(buf2, mode)) != NULL)
|
||||||
return (fp);
|
return (fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If this is an abs pathname, or there is no sourcepath var, just
|
/* If this is an abs pathname, or there is no sourcepath var, just
|
||||||
* do an fopen.
|
* do an fopen.
|
||||||
*/
|
*/
|
||||||
|
|
@ -886,15 +897,16 @@ inp_pathopen(char *name, char *mode)
|
||||||
return (fopen(name, mode));
|
return (fopen(name, mode));
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
/* If this is an abs pathname, or there is no sourcepath var, just
|
/* If this is an abs pathname, or there is no sourcepath var, just
|
||||||
* do an fopen.
|
* do an fopen.
|
||||||
*/
|
*/
|
||||||
if (strchr(name, DIR_TERM) || !cp_getvar("sourcepath", CP_LIST, &v))
|
if (strchr(name, DIR_TERM) || !cp_getvar("sourcepath", CP_LIST, &v))
|
||||||
return (fopen(name, mode));
|
return (fopen(name, mode));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (; v; v = v->va_next) {
|
for (; v; v = v->va_next) {
|
||||||
|
|
||||||
switch (v->va_type) {
|
switch (v->va_type) {
|
||||||
case CP_STRING:
|
case CP_STRING:
|
||||||
cp_wstrip(v->va_string);
|
cp_wstrip(v->va_string);
|
||||||
|
|
@ -906,17 +918,20 @@ inp_pathopen(char *name, char *mode)
|
||||||
case CP_REAL: /* This is foolish */
|
case CP_REAL: /* This is foolish */
|
||||||
(void) sprintf(buf, "%g%s%s", v->va_real, DIR_PATHSEP, name);
|
(void) sprintf(buf, "%g%s%s", v->va_real, DIR_PATHSEP, name);
|
||||||
break;
|
break;
|
||||||
default: {
|
default:
|
||||||
fprintf(stderr, "ERROR: enumeration value `CP_BOOL' or `CP_LIST' not handled in inp_pathopen\nAborting...\n");
|
fprintf(stderr, "ERROR: enumeration value `CP_BOOL' or `CP_LIST' not handled in inp_pathopen\nAborting...\n");
|
||||||
controlled_exit(EXIT_FAILURE);
|
controlled_exit(EXIT_FAILURE);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ((fp = fopen(buf, mode)) != NULL)
|
if ((fp = fopen(buf, mode)) != NULL)
|
||||||
return (fp);
|
return (fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*
|
/*-------------------------------------------------------------------------*
|
||||||
* This routine reads a line (of arbitrary length), up to a '\n' or 'EOF' *
|
* This routine reads a line (of arbitrary length), up to a '\n' or 'EOF' *
|
||||||
* and returns a pointer to the resulting null terminated string. *
|
* and returns a pointer to the resulting null terminated string. *
|
||||||
|
|
@ -924,6 +939,7 @@ inp_pathopen(char *name, char *mode)
|
||||||
* From: jason@ucbopal.BERKELEY.EDU (Jason Venner) *
|
* From: jason@ucbopal.BERKELEY.EDU (Jason Venner) *
|
||||||
* Newsgroups: net.sources *
|
* Newsgroups: net.sources *
|
||||||
*-------------------------------------------------------------------------*/
|
*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#define STRGROW 256
|
#define STRGROW 256
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
|
@ -938,38 +954,48 @@ readline(FILE *fd)
|
||||||
memlen = STRGROW;
|
memlen = STRGROW;
|
||||||
strptr = TMALLOC(char, memlen);
|
strptr = TMALLOC(char, memlen);
|
||||||
memlen -= 1; /* Save constant -1's in while loop */
|
memlen -= 1; /* Save constant -1's in while loop */
|
||||||
|
|
||||||
while ((c = getc(fd)) != EOF) {
|
while ((c = getc(fd)) != EOF) {
|
||||||
|
|
||||||
if (strlen == 0 && (c == '\t' || c == ' ')) /* Leading spaces away */
|
if (strlen == 0 && (c == '\t' || c == ' ')) /* Leading spaces away */
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
strptr[strlen++] = (char) c;
|
strptr[strlen++] = (char) c;
|
||||||
|
|
||||||
if (strlen >= memlen) {
|
if (strlen >= memlen) {
|
||||||
memlen += STRGROW;
|
memlen += STRGROW;
|
||||||
if ((strptr = TREALLOC(char, strptr, memlen + 1)) == NULL)
|
if ((strptr = TREALLOC(char, strptr, memlen + 1)) == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strlen) {
|
if (!strlen) {
|
||||||
tfree(strptr);
|
tfree(strptr);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// strptr[strlen] = '\0';
|
// strptr[strlen] = '\0';
|
||||||
/* Trim the string */
|
/* Trim the string */
|
||||||
strptr = TREALLOC(char, strptr, strlen + 1);
|
strptr = TREALLOC(char, strptr, strlen + 1);
|
||||||
strptr[strlen] = '\0';
|
strptr[strlen] = '\0';
|
||||||
|
|
||||||
return (strptr);
|
return (strptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* replace "gnd" by " 0 "
|
/* replace "gnd" by " 0 "
|
||||||
Delimiters of gnd may be ' ' or ',' or '(' or ')' */
|
Delimiters of gnd may be ' ' or ',' or '(' or ')' */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
inp_fix_gnd_name(struct line *c)
|
inp_fix_gnd_name(struct line *c)
|
||||||
{
|
{
|
||||||
|
|
||||||
for (; c; c = c->li_next) {
|
for (; c; c = c->li_next) {
|
||||||
|
|
||||||
char *gnd = c->li_line;
|
char *gnd = c->li_line;
|
||||||
|
|
||||||
// if there is a comment or no gnd, go to next line
|
// if there is a comment or no gnd, go to next line
|
||||||
if ((*gnd == '*') || !strstr(gnd, "gnd"))
|
if ((*gnd == '*') || !strstr(gnd, "gnd"))
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -982,6 +1008,7 @@ inp_fix_gnd_name(struct line *c)
|
||||||
}
|
}
|
||||||
gnd += 3;
|
gnd += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// now remove the extra white spaces around 0
|
// now remove the extra white spaces around 0
|
||||||
c->li_line = inp_remove_ws(c->li_line);
|
c->li_line = inp_remove_ws(c->li_line);
|
||||||
}
|
}
|
||||||
|
|
@ -994,6 +1021,7 @@ inp_chk_for_multi_in_vcvs(struct line *c, int *line_number)
|
||||||
int skip_control = 0;
|
int skip_control = 0;
|
||||||
|
|
||||||
for (; c; c = c->li_next) {
|
for (; c; c = c->li_next) {
|
||||||
|
|
||||||
char *line = c->li_line;
|
char *line = c->li_line;
|
||||||
|
|
||||||
/* there is no e source inside .control ... .endc */
|
/* there is no e source inside .control ... .endc */
|
||||||
|
|
@ -1114,19 +1142,24 @@ inp_add_control_section(struct line *deck, int *line_number)
|
||||||
char *op_line = NULL, rawfile[1000], *line;
|
char *op_line = NULL, rawfile[1000], *line;
|
||||||
|
|
||||||
for (c = deck; c; c = c->li_next) {
|
for (c = deck; c; c = c->li_next) {
|
||||||
|
|
||||||
if (*c->li_line == '*')
|
if (*c->li_line == '*')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ciprefix(".op ", c->li_line)) {
|
if (ciprefix(".op ", c->li_line)) {
|
||||||
*c->li_line = '*';
|
*c->li_line = '*';
|
||||||
op_line = c->li_line + 1;
|
op_line = c->li_line + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ciprefix(".end", c->li_line))
|
if (ciprefix(".end", c->li_line))
|
||||||
found_end = TRUE;
|
found_end = TRUE;
|
||||||
|
|
||||||
if (found_control && ciprefix("run", c->li_line))
|
if (found_control && ciprefix("run", c->li_line))
|
||||||
found_run = TRUE;
|
found_run = TRUE;
|
||||||
|
|
||||||
if (ciprefix(".control", c->li_line))
|
if (ciprefix(".control", c->li_line))
|
||||||
found_control = TRUE;
|
found_control = TRUE;
|
||||||
|
|
||||||
if (ciprefix(".endc", c->li_line)) {
|
if (ciprefix(".endc", c->li_line)) {
|
||||||
found_control = FALSE;
|
found_control = FALSE;
|
||||||
|
|
||||||
|
|
@ -1135,6 +1168,7 @@ inp_add_control_section(struct line *deck, int *line_number)
|
||||||
prev_card = prev_card->li_next;
|
prev_card = prev_card->li_next;
|
||||||
found_run = TRUE;
|
found_run = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cp_getvar("rawfile", CP_STRING, rawfile)) {
|
if (cp_getvar("rawfile", CP_STRING, rawfile)) {
|
||||||
line = TMALLOC(char, strlen("write") + strlen(rawfile) + 2);
|
line = TMALLOC(char, strlen("write") + strlen(rawfile) + 2);
|
||||||
sprintf(line, "write %s", rawfile);
|
sprintf(line, "write %s", rawfile);
|
||||||
|
|
@ -1142,6 +1176,7 @@ inp_add_control_section(struct line *deck, int *line_number)
|
||||||
prev_card = prev_card->li_next;
|
prev_card = prev_card->li_next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prev_card = c;
|
prev_card = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1167,10 +1202,12 @@ inp_add_control_section(struct line *deck, int *line_number)
|
||||||
|
|
||||||
|
|
||||||
// look for shell-style end-of-line continuation '\\'
|
// look for shell-style end-of-line continuation '\\'
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
chk_for_line_continuation(char *line)
|
chk_for_line_continuation(char *line)
|
||||||
{
|
{
|
||||||
if (*line != '*' && *line != '$') {
|
if (*line != '*' && *line != '$') {
|
||||||
|
|
||||||
char *ptr = skip_back_ws_(strchr(line, '\0'), line);
|
char *ptr = skip_back_ws_(strchr(line, '\0'), line);
|
||||||
|
|
||||||
if ((ptr - 2 >= line) && (ptr[-1] == '\\') && (ptr[-2] == '\\')) {
|
if ((ptr - 2 >= line) && (ptr[-1] == '\\') && (ptr[-2] == '\\')) {
|
||||||
|
|
@ -1237,6 +1274,7 @@ inp_fix_macro_param_func_paren_io(struct line *card)
|
||||||
card->li_line = inp_remove_ws(card->li_line); /* remove the extra white spaces just introduced */
|
card->li_line = inp_remove_ws(card->li_line); /* remove the extra white spaces just introduced */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ciprefix(".param", card->li_line)) {
|
if (ciprefix(".param", card->li_line)) {
|
||||||
bool is_func = FALSE;
|
bool is_func = FALSE;
|
||||||
str_ptr = skip_non_ws(card->li_line); // skip over .param
|
str_ptr = skip_non_ws(card->li_line); // skip over .param
|
||||||
|
|
@ -1280,6 +1318,7 @@ get_instance_subckt(char *line)
|
||||||
end_ptr = skip_back_ws_(end_ptr, line);
|
end_ptr = skip_back_ws_(end_ptr, line);
|
||||||
|
|
||||||
inst_name_ptr = skip_back_non_ws_(end_ptr, line);
|
inst_name_ptr = skip_back_non_ws_(end_ptr, line);
|
||||||
|
|
||||||
return copy_substring(inst_name_ptr, end_ptr);
|
return copy_substring(inst_name_ptr, end_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1293,6 +1332,7 @@ get_subckt_model_name(char *line)
|
||||||
name = skip_ws(name);
|
name = skip_ws(name);
|
||||||
|
|
||||||
end_ptr = skip_non_ws(name);
|
end_ptr = skip_non_ws(name);
|
||||||
|
|
||||||
return copy_substring(name, end_ptr);
|
return copy_substring(name, end_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1310,6 +1350,7 @@ get_model_name(char *line, int num_terminals)
|
||||||
beg_ptr = skip_non_ws(beg_ptr);
|
beg_ptr = skip_non_ws(beg_ptr);
|
||||||
beg_ptr = skip_ws(beg_ptr);
|
beg_ptr = skip_ws(beg_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*line == 'r') /* special dealing for r models */
|
if (*line == 'r') /* special dealing for r models */
|
||||||
if ((*beg_ptr == '+') || (*beg_ptr == '-') || isdigit(*beg_ptr)) { /* looking for a value before model */
|
if ((*beg_ptr == '+') || (*beg_ptr == '-') || isdigit(*beg_ptr)) { /* looking for a value before model */
|
||||||
beg_ptr = skip_non_ws(beg_ptr); /* skip the value */
|
beg_ptr = skip_non_ws(beg_ptr); /* skip the value */
|
||||||
|
|
@ -1317,6 +1358,7 @@ get_model_name(char *line, int num_terminals)
|
||||||
}
|
}
|
||||||
|
|
||||||
end_ptr = skip_non_ws(beg_ptr);
|
end_ptr = skip_non_ws(beg_ptr);
|
||||||
|
|
||||||
return copy_substring(beg_ptr, end_ptr);
|
return copy_substring(beg_ptr, end_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1325,12 +1367,16 @@ static char*
|
||||||
get_model_type(char *line)
|
get_model_type(char *line)
|
||||||
{
|
{
|
||||||
char *beg_ptr;
|
char *beg_ptr;
|
||||||
|
|
||||||
if (!ciprefix(".model", line))
|
if (!ciprefix(".model", line))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
beg_ptr = skip_non_ws(line); /* eat .model */
|
beg_ptr = skip_non_ws(line); /* eat .model */
|
||||||
beg_ptr = skip_ws(beg_ptr);
|
beg_ptr = skip_ws(beg_ptr);
|
||||||
|
|
||||||
beg_ptr = skip_non_ws(beg_ptr); /* eat model name */
|
beg_ptr = skip_non_ws(beg_ptr); /* eat model name */
|
||||||
beg_ptr = skip_ws(beg_ptr);
|
beg_ptr = skip_ws(beg_ptr);
|
||||||
|
|
||||||
return gettok(&beg_ptr);
|
return gettok(&beg_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1342,6 +1388,7 @@ get_adevice_model_name(char *line)
|
||||||
|
|
||||||
ptr_end = skip_back_ws_(strchr(line, '\0'), line);
|
ptr_end = skip_back_ws_(strchr(line, '\0'), line);
|
||||||
ptr_beg = skip_back_non_ws_(ptr_end, line);
|
ptr_beg = skip_back_non_ws_(ptr_end, line);
|
||||||
|
|
||||||
return copy_substring(ptr_beg, ptr_end);
|
return copy_substring(ptr_beg, ptr_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1358,6 +1405,7 @@ get_subckts_for_subckt(struct line *start_card, char *subckt_name,
|
||||||
int i, num_terminals = 0, tmp_cnt = 0;
|
int i, num_terminals = 0, tmp_cnt = 0;
|
||||||
|
|
||||||
for (card = start_card; card; card = card->li_next) {
|
for (card = start_card; card; card = card->li_next) {
|
||||||
|
|
||||||
char *line = card->li_line;
|
char *line = card->li_line;
|
||||||
|
|
||||||
if (*line == '*')
|
if (*line == '*')
|
||||||
|
|
@ -1374,6 +1422,7 @@ get_subckts_for_subckt(struct line *start_card, char *subckt_name,
|
||||||
|
|
||||||
tfree(curr_subckt_name);
|
tfree(curr_subckt_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found_subckt) {
|
if (found_subckt) {
|
||||||
if (*line == 'x') {
|
if (*line == 'x') {
|
||||||
inst_subckt_name = get_instance_subckt(line);
|
inst_subckt_name = get_instance_subckt(line);
|
||||||
|
|
@ -1431,6 +1480,7 @@ get_subckts_for_subckt(struct line *start_card, char *subckt_name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// now make recursive call on instances just found above
|
// now make recursive call on instances just found above
|
||||||
for (i = 0; i < tmp_cnt; i++)
|
for (i = 0; i < tmp_cnt; i++)
|
||||||
get_subckts_for_subckt(start_card, new_names[i], used_subckt_names, num_used_subckt_names,
|
get_subckts_for_subckt(start_card, new_names[i], used_subckt_names, num_used_subckt_names,
|
||||||
|
|
@ -1441,6 +1491,7 @@ get_subckts_for_subckt(struct line *start_card, char *subckt_name,
|
||||||
/*
|
/*
|
||||||
check if current token matches model bin name -- <token>.[0-9]+
|
check if current token matches model bin name -- <token>.[0-9]+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
model_bin_match(char *token, char *model_name)
|
model_bin_match(char *token, char *model_name)
|
||||||
{
|
{
|
||||||
|
|
@ -1469,6 +1520,7 @@ model_bin_match(char *token, char *model_name)
|
||||||
(don't want to waste time processing everything)
|
(don't want to waste time processing everything)
|
||||||
also comment out .param lines with no parameters defined
|
also comment out .param lines with no parameters defined
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
comment_out_unused_subckt_models(struct line *start_card, int no_of_lines)
|
comment_out_unused_subckt_models(struct line *start_card, int no_of_lines)
|
||||||
{
|
{
|
||||||
|
|
@ -1482,6 +1534,7 @@ comment_out_unused_subckt_models(struct line *start_card, int no_of_lines)
|
||||||
with 1000, but increase, if number of lines in deck is larger */
|
with 1000, but increase, if number of lines in deck is larger */
|
||||||
if (no_of_lines < 1000)
|
if (no_of_lines < 1000)
|
||||||
no_of_lines = 1000;
|
no_of_lines = 1000;
|
||||||
|
|
||||||
used_subckt_names = TMALLOC(char*, no_of_lines);
|
used_subckt_names = TMALLOC(char*, no_of_lines);
|
||||||
used_model_names = TMALLOC(char*, no_of_lines);
|
used_model_names = TMALLOC(char*, no_of_lines);
|
||||||
|
|
||||||
|
|
@ -1495,6 +1548,7 @@ comment_out_unused_subckt_models(struct line *start_card, int no_of_lines)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (card = start_card; card; card = card->li_next) {
|
for (card = start_card; card; card = card->li_next) {
|
||||||
|
|
||||||
char *line = card->li_line;
|
char *line = card->li_line;
|
||||||
|
|
||||||
if (*line == '*')
|
if (*line == '*')
|
||||||
|
|
@ -1578,6 +1632,7 @@ comment_out_unused_subckt_models(struct line *start_card, int no_of_lines)
|
||||||
} /* if (has_models) */
|
} /* if (has_models) */
|
||||||
} /* if (!processing_subckt) */
|
} /* if (!processing_subckt) */
|
||||||
} /* for loop through all cards */
|
} /* for loop through all cards */
|
||||||
|
|
||||||
for (i = 0; i < tmp_cnt; i++)
|
for (i = 0; i < tmp_cnt; i++)
|
||||||
get_subckts_for_subckt
|
get_subckts_for_subckt
|
||||||
(start_card, used_subckt_names[i],
|
(start_card, used_subckt_names[i],
|
||||||
|
|
@ -1586,6 +1641,7 @@ comment_out_unused_subckt_models(struct line *start_card, int no_of_lines)
|
||||||
|
|
||||||
/* comment out any unused subckts, currently only at top level */
|
/* comment out any unused subckts, currently only at top level */
|
||||||
for (card = start_card; card; card = card->li_next) {
|
for (card = start_card; card; card = card->li_next) {
|
||||||
|
|
||||||
char *line = card->li_line;
|
char *line = card->li_line;
|
||||||
|
|
||||||
if (*line == '*')
|
if (*line == '*')
|
||||||
|
|
@ -1603,6 +1659,7 @@ comment_out_unused_subckt_models(struct line *start_card, int no_of_lines)
|
||||||
}
|
}
|
||||||
tfree(subckt_name);
|
tfree(subckt_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ciprefix(".ends", line) || ciprefix(".eom", line)) {
|
if (ciprefix(".ends", line) || ciprefix(".eom", line)) {
|
||||||
nested_subckt--;
|
nested_subckt--;
|
||||||
if (remove_subckt)
|
if (remove_subckt)
|
||||||
|
|
@ -1610,6 +1667,7 @@ comment_out_unused_subckt_models(struct line *start_card, int no_of_lines)
|
||||||
if (nested_subckt == 0)
|
if (nested_subckt == 0)
|
||||||
remove_subckt = FALSE;
|
remove_subckt = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remove_subckt)
|
if (remove_subckt)
|
||||||
*line = '*';
|
*line = '*';
|
||||||
else if (has_models &&
|
else if (has_models &&
|
||||||
|
|
@ -1638,6 +1696,7 @@ comment_out_unused_subckt_models(struct line *start_card, int no_of_lines)
|
||||||
tfree(model_name);
|
tfree(model_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < num_used_subckt_names; i++)
|
for (i = 0; i < num_used_subckt_names; i++)
|
||||||
tfree(used_subckt_names[i]);
|
tfree(used_subckt_names[i]);
|
||||||
for (i = 0; i < num_used_model_names; i++)
|
for (i = 0; i < num_used_model_names; i++)
|
||||||
|
|
@ -1649,6 +1708,7 @@ comment_out_unused_subckt_models(struct line *start_card, int no_of_lines)
|
||||||
|
|
||||||
/* replace ternary operator ? : by fcn ternary_fcn() in .param, .func, and .meas lines,
|
/* replace ternary operator ? : by fcn ternary_fcn() in .param, .func, and .meas lines,
|
||||||
if all is FALSE, for all lines if all is TRUE */
|
if all is FALSE, for all lines if all is TRUE */
|
||||||
|
|
||||||
static char*
|
static char*
|
||||||
inp_fix_ternary_operator_str(char *line, bool all)
|
inp_fix_ternary_operator_str(char *line, bool all)
|
||||||
{
|
{
|
||||||
|
|
@ -1685,6 +1745,7 @@ inp_fix_ternary_operator_str(char *line, bool all)
|
||||||
} else {
|
} else {
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
all = TRUE;
|
all = TRUE;
|
||||||
// get conditional
|
// get conditional
|
||||||
question = strchr(str_ptr, '?');
|
question = strchr(str_ptr, '?');
|
||||||
|
|
@ -1821,21 +1882,25 @@ inp_fix_ternary_operator(struct line *card)
|
||||||
bool found_control = FALSE;
|
bool found_control = FALSE;
|
||||||
|
|
||||||
for (; card; card = card->li_next) {
|
for (; card; card = card->li_next) {
|
||||||
|
|
||||||
char *line = card->li_line;
|
char *line = card->li_line;
|
||||||
|
|
||||||
if (*line == '*')
|
if (*line == '*')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* exclude replacement of ternary function between .control and .endc */
|
/* exclude replacement of ternary function between .control and .endc */
|
||||||
if (ciprefix(".control", line))
|
if (ciprefix(".control", line))
|
||||||
found_control = TRUE;
|
found_control = TRUE;
|
||||||
if (ciprefix(".endc", line))
|
if (ciprefix(".endc", line))
|
||||||
found_control = FALSE;
|
found_control = FALSE;
|
||||||
|
|
||||||
if (found_control)
|
if (found_control)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* ternary operator for B source done elsewhere */
|
/* ternary operator for B source done elsewhere */
|
||||||
if (*line == 'B' || *line == 'b')
|
if (*line == 'B' || *line == 'b')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* .param, .func, and .meas lines handled here (2nd argument FALSE) */
|
/* .param, .func, and .meas lines handled here (2nd argument FALSE) */
|
||||||
if (strchr(line, '?') && strchr(line, ':'))
|
if (strchr(line, '?') && strchr(line, ':'))
|
||||||
card->li_line = inp_fix_ternary_operator_str(line, FALSE);
|
card->li_line = inp_fix_ternary_operator_str(line, FALSE);
|
||||||
|
|
@ -1847,6 +1912,7 @@ inp_fix_ternary_operator(struct line *card)
|
||||||
removes " " quotes, returns lower case letters,
|
removes " " quotes, returns lower case letters,
|
||||||
replaces non-printable characterss with '_' *
|
replaces non-printable characterss with '_' *
|
||||||
*-------------------------------------------------------------------------*/
|
*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
void
|
void
|
||||||
inp_casefix(char *string)
|
inp_casefix(char *string)
|
||||||
{
|
{
|
||||||
|
|
@ -1904,6 +1970,7 @@ inp_stripcomments_deck(struct line *c)
|
||||||
the whole line is converted to a normal comment line (i.e. one that
|
the whole line is converted to a normal comment line (i.e. one that
|
||||||
begins with a '*').
|
begins with a '*').
|
||||||
BUG: comment characters in side of string literals are not ignored. */
|
BUG: comment characters in side of string literals are not ignored. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
inp_stripcomments_line(char *s)
|
inp_stripcomments_line(char *s)
|
||||||
{
|
{
|
||||||
|
|
@ -2150,6 +2217,7 @@ inp_fix_subckt(struct names *subckt_w_params, char *s)
|
||||||
|
|
||||||
s = buffer;
|
s = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2214,12 +2282,14 @@ inp_remove_ws(char *s)
|
||||||
modify .subckt lines by calling inp_fix_subckt()
|
modify .subckt lines by calling inp_fix_subckt()
|
||||||
No changes to lines in .control section !
|
No changes to lines in .control section !
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
inp_fix_for_numparam(struct names *subckt_w_params, struct line *c)
|
inp_fix_for_numparam(struct names *subckt_w_params, struct line *c)
|
||||||
{
|
{
|
||||||
bool found_control = FALSE;
|
bool found_control = FALSE;
|
||||||
|
|
||||||
for (; c; c = c->li_next) {
|
for (; c; c = c->li_next) {
|
||||||
|
|
||||||
if (ciprefix(".lib", c->li_line) || ciprefix("*lib", c->li_line) || ciprefix("*inc", c->li_line))
|
if (ciprefix(".lib", c->li_line) || ciprefix("*lib", c->li_line) || ciprefix("*inc", c->li_line))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
@ -2228,6 +2298,7 @@ inp_fix_for_numparam(struct names *subckt_w_params, struct line *c)
|
||||||
found_control = TRUE;
|
found_control = TRUE;
|
||||||
if (ciprefix(".endc", c->li_line))
|
if (ciprefix(".endc", c->li_line))
|
||||||
found_control = FALSE;
|
found_control = FALSE;
|
||||||
|
|
||||||
if (found_control)
|
if (found_control)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
@ -2251,7 +2322,9 @@ static void
|
||||||
inp_remove_excess_ws(struct line *c)
|
inp_remove_excess_ws(struct line *c)
|
||||||
{
|
{
|
||||||
bool found_control = FALSE;
|
bool found_control = FALSE;
|
||||||
|
|
||||||
for (; c; c = c->li_next) {
|
for (; c; c = c->li_next) {
|
||||||
|
|
||||||
if (*c->li_line == '*')
|
if (*c->li_line == '*')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
@ -2260,6 +2333,7 @@ inp_remove_excess_ws(struct line *c)
|
||||||
found_control = TRUE;
|
found_control = TRUE;
|
||||||
if (ciprefix(".endc", c->li_line))
|
if (ciprefix(".endc", c->li_line))
|
||||||
found_control = FALSE;
|
found_control = FALSE;
|
||||||
|
|
||||||
if (found_control && ciprefix("echo", c->li_line))
|
if (found_control && ciprefix("echo", c->li_line))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
@ -2487,9 +2561,11 @@ inp_fix_inst_line(char *inst_line,
|
||||||
return curr_line;
|
return curr_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* If multiplier parameter 'm' is found on a X line, flag is set
|
/* If multiplier parameter 'm' is found on a X line, flag is set
|
||||||
to TRUE.
|
to TRUE.
|
||||||
Function is called from inp_fix_inst_calls_for_numparam()*/
|
Function is called from inp_fix_inst_calls_for_numparam()*/
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
found_mult_param(int num_params, char *param_names[])
|
found_mult_param(int num_params, char *param_names[])
|
||||||
{
|
{
|
||||||
|
|
@ -2502,6 +2578,7 @@ found_mult_param(int num_params, char *param_names[])
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* If a subcircuit invocation (X-line) is found, which contains the
|
/* If a subcircuit invocation (X-line) is found, which contains the
|
||||||
multiplier parameter 'm', m is added to all lines inside
|
multiplier parameter 'm', m is added to all lines inside
|
||||||
the corresponding subcircuit except of some excluded in the code below
|
the corresponding subcircuit except of some excluded in the code below
|
||||||
|
|
@ -2509,6 +2586,7 @@ found_mult_param(int num_params, char *param_names[])
|
||||||
for all devices that are not supporting the 'm' parameter).
|
for all devices that are not supporting the 'm' parameter).
|
||||||
|
|
||||||
Function is called from inp_fix_inst_calls_for_numparam()*/
|
Function is called from inp_fix_inst_calls_for_numparam()*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
inp_fix_subckt_multiplier(struct names *subckt_w_params, struct line *subckt_card,
|
inp_fix_subckt_multiplier(struct names *subckt_w_params, struct line *subckt_card,
|
||||||
int num_subckt_params, char *subckt_param_names[], char *subckt_param_values[])
|
int num_subckt_params, char *subckt_param_names[], char *subckt_param_values[])
|
||||||
|
|
@ -2586,6 +2664,7 @@ inp_fix_inst_calls_for_numparam(struct names *subckt_w_params, struct line *deck
|
||||||
if (found_mult_param(num_inst_params, inst_param_names)) {
|
if (found_mult_param(num_inst_params, inst_param_names)) {
|
||||||
flag = FALSE;
|
flag = FALSE;
|
||||||
// iterate through the deck to find the subckt (last one defined wins)
|
// iterate through the deck to find the subckt (last one defined wins)
|
||||||
|
|
||||||
for (d = deck; d; d = d->li_next) {
|
for (d = deck; d; d = d->li_next) {
|
||||||
char *subckt_line = d->li_line;
|
char *subckt_line = d->li_line;
|
||||||
if (ciprefix(".subckt", subckt_line)) {
|
if (ciprefix(".subckt", subckt_line)) {
|
||||||
|
|
@ -2622,9 +2701,9 @@ inp_fix_inst_calls_for_numparam(struct names *subckt_w_params, struct line *deck
|
||||||
for (c = deck; c; c = c->li_next) {
|
for (c = deck; c; c = c->li_next) {
|
||||||
char *inst_line = c->li_line;
|
char *inst_line = c->li_line;
|
||||||
|
|
||||||
if (*inst_line == '*') {
|
if (*inst_line == '*')
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
if (ciprefix("x", inst_line)) {
|
if (ciprefix("x", inst_line)) {
|
||||||
subckt_name = inp_get_subckt_name(inst_line);
|
subckt_name = inp_get_subckt_name(inst_line);
|
||||||
|
|
||||||
|
|
@ -2843,12 +2922,14 @@ inp_do_macro_param_replace(struct function *fcn, char *params[])
|
||||||
return strdup(fcn->macro);
|
return strdup(fcn->macro);
|
||||||
|
|
||||||
for (i = 0; i < fcn->num_parameters; i++) {
|
for (i = 0; i < fcn->num_parameters; i++) {
|
||||||
|
|
||||||
if (curr_str == NULL) {
|
if (curr_str == NULL) {
|
||||||
search_ptr = curr_ptr = fcn->macro;
|
search_ptr = curr_ptr = fcn->macro;
|
||||||
} else {
|
} else {
|
||||||
search_ptr = curr_ptr = curr_str;
|
search_ptr = curr_ptr = curr_str;
|
||||||
curr_str = NULL;
|
curr_str = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((param_ptr = strstr(search_ptr, fcn->params[i])) != NULL) {
|
while ((param_ptr = strstr(search_ptr, fcn->params[i])) != NULL) {
|
||||||
|
|
||||||
/* make sure actually have the parameter name */
|
/* make sure actually have the parameter name */
|
||||||
|
|
@ -2884,6 +2965,7 @@ inp_do_macro_param_replace(struct function *fcn, char *params[])
|
||||||
*param_ptr = keep;
|
*param_ptr = keep;
|
||||||
search_ptr = curr_ptr = param_ptr + strlen(fcn->params[i]);
|
search_ptr = curr_ptr = param_ptr + strlen(fcn->params[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (param_ptr == NULL) {
|
if (param_ptr == NULL) {
|
||||||
if (curr_str == NULL) {
|
if (curr_str == NULL) {
|
||||||
curr_str = curr_ptr;
|
curr_str = curr_ptr;
|
||||||
|
|
@ -2895,6 +2977,7 @@ inp_do_macro_param_replace(struct function *fcn, char *params[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return curr_str;
|
return curr_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3087,6 +3170,7 @@ inp_expand_macros_in_deck(struct function_env *env, struct line *c)
|
||||||
}
|
}
|
||||||
|
|
||||||
env = delete_function_env(env);
|
env = delete_function_env(env);
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3104,6 +3188,7 @@ inp_expand_macros_in_deck(struct function_env *env, struct line *c)
|
||||||
* Usage of numparam requires {} around the parameters in the .cmodel line.
|
* Usage of numparam requires {} around the parameters in the .cmodel line.
|
||||||
* May be obsolete?
|
* May be obsolete?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
inp_fix_param_values(struct line *c)
|
inp_fix_param_values(struct line *c)
|
||||||
{
|
{
|
||||||
|
|
@ -3123,6 +3208,7 @@ inp_fix_param_values(struct line *c)
|
||||||
control_section = TRUE;
|
control_section = TRUE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ciprefix(".endc", line)) {
|
if (ciprefix(".endc", line)) {
|
||||||
control_section = FALSE;
|
control_section = FALSE;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -3369,7 +3455,6 @@ get_param_str(char *line)
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
//inp_get_param_level(int param_num, char *depends_on[12000][100], char *param_names[12000], char *param_strs[12000], int total_params, int *level)
|
|
||||||
inp_get_param_level(int param_num, char ***depends_on, char **param_names, char **param_strs, int total_params, int *level)
|
inp_get_param_level(int param_num, char ***depends_on, char **param_names, char **param_strs, int total_params, int *level)
|
||||||
{
|
{
|
||||||
int index1 = 0, comp_level = 0, temp_level = 0;
|
int index1 = 0, comp_level = 0, temp_level = 0;
|
||||||
|
|
@ -3395,7 +3480,9 @@ inp_get_param_level(int param_num, char ***depends_on, char **param_names, char
|
||||||
comp_level = temp_level;
|
comp_level = temp_level;
|
||||||
index1++;
|
index1++;
|
||||||
}
|
}
|
||||||
|
|
||||||
level[param_num] = comp_level;
|
level[param_num] = comp_level;
|
||||||
|
|
||||||
return comp_level;
|
return comp_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3512,6 +3599,7 @@ get_number_terminals(char *c)
|
||||||
|
|
||||||
|
|
||||||
/* sort parameters based on parameter dependencies */
|
/* sort parameters based on parameter dependencies */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
inp_sort_params(struct line *start_card, struct line *end_card, struct line *card_bf_start, struct line *s_c, struct line *e_c)
|
inp_sort_params(struct line *start_card, struct line *end_card, struct line *card_bf_start, struct line *s_c, struct line *e_c)
|
||||||
{
|
{
|
||||||
|
|
@ -3540,6 +3628,7 @@ inp_sort_params(struct line *start_card, struct line *end_card, struct line *car
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* determine the number of lines with .param */
|
/* determine the number of lines with .param */
|
||||||
|
|
||||||
for (ptr = start_card; ptr; ptr = ptr->li_next)
|
for (ptr = start_card; ptr; ptr = ptr->li_next)
|
||||||
if (strchr(ptr->li_line, '='))
|
if (strchr(ptr->li_line, '='))
|
||||||
num_params++;
|
num_params++;
|
||||||
|
|
@ -3634,27 +3723,29 @@ inp_sort_params(struct line *start_card, struct line *end_card, struct line *car
|
||||||
}
|
}
|
||||||
|
|
||||||
/* look for unquoted parameters and quote them */
|
/* look for unquoted parameters and quote them */
|
||||||
|
|
||||||
in_control = FALSE;
|
in_control = FALSE;
|
||||||
for (ptr = s_c; ptr && ptr != e_c; ptr = ptr->li_next) {
|
for (ptr = s_c; ptr && ptr != e_c; ptr = ptr->li_next) {
|
||||||
|
|
||||||
char *curr_line = ptr->li_line;
|
char *curr_line = ptr->li_line;
|
||||||
|
|
||||||
if (ciprefix(".control", curr_line)) {
|
if (ciprefix(".control", curr_line)) {
|
||||||
in_control = TRUE;
|
in_control = TRUE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ciprefix(".endc", curr_line)) {
|
if (ciprefix(".endc", curr_line)) {
|
||||||
in_control = FALSE;
|
in_control = FALSE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (in_control || curr_line[0] == '.' || curr_line[0] == '*') {
|
|
||||||
|
if (in_control || curr_line[0] == '.' || curr_line[0] == '*')
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
num_terminals = get_number_terminals(curr_line);
|
num_terminals = get_number_terminals(curr_line);
|
||||||
|
|
||||||
if (num_terminals <= 0) {
|
if (num_terminals <= 0)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < num_params; i++) {
|
for (i = 0; i < num_params; i++) {
|
||||||
str_ptr = curr_line;
|
str_ptr = curr_line;
|
||||||
|
|
@ -3906,6 +3997,7 @@ inp_reorder_params(struct names *subckt_w_params, struct line *deck, struct line
|
||||||
//
|
//
|
||||||
// split line up into multiple lines and place those new lines immediately
|
// split line up into multiple lines and place those new lines immediately
|
||||||
// afetr the current multi-param line in the deck
|
// afetr the current multi-param line in the deck
|
||||||
|
|
||||||
static int
|
static int
|
||||||
inp_split_multi_param_lines(struct line *card, int line_num)
|
inp_split_multi_param_lines(struct line *card, int line_num)
|
||||||
{
|
{
|
||||||
|
|
@ -4043,6 +4135,7 @@ inp_split_multi_param_lines(struct line *card, int line_num)
|
||||||
Bxxx n1 n2 V = v(n-aux) * 1e-16
|
Bxxx n1 n2 V = v(n-aux) * 1e-16
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
inp_compat(struct line *card)
|
inp_compat(struct line *card)
|
||||||
{
|
{
|
||||||
|
|
@ -5073,8 +5166,10 @@ inp_compat(struct line *card)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* replace a token (length 4 char) in string by spaces, if it is found
|
/* replace a token (length 4 char) in string by spaces, if it is found
|
||||||
at the correct position and the total number of tokens is o.k. */
|
at the correct position and the total number of tokens is o.k. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
replace_token(char *string, char *token, int wherereplace, int total)
|
replace_token(char *string, char *token, int wherereplace, int total)
|
||||||
{
|
{
|
||||||
|
|
@ -5540,18 +5635,24 @@ inp_add_series_resistor(struct line *deck)
|
||||||
tfree(rval);
|
tfree(rval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* If XSPICE option is not selected, run this function to alert and exit
|
/* If XSPICE option is not selected, run this function to alert and exit
|
||||||
if the 'poly' option is found in e, g, f, or h controlled sources. */
|
if the 'poly' option is found in e, g, f, or h controlled sources. */
|
||||||
|
|
||||||
#ifndef XSPICE
|
#ifndef XSPICE
|
||||||
|
|
||||||
static void
|
static void
|
||||||
inp_poly_err(struct line *card)
|
inp_poly_err(struct line *card)
|
||||||
{
|
{
|
||||||
size_t skip_control = 0;
|
size_t skip_control = 0;
|
||||||
|
|
||||||
for (; card; card = card->li_next) {
|
for (; card; card = card->li_next) {
|
||||||
|
|
||||||
char *curr_line = card->li_line;
|
char *curr_line = card->li_line;
|
||||||
|
|
||||||
if (*curr_line == '*')
|
if (*curr_line == '*')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* exclude any command inside .control ... .endc */
|
/* exclude any command inside .control ... .endc */
|
||||||
if (ciprefix(".control", curr_line)) {
|
if (ciprefix(".control", curr_line)) {
|
||||||
skip_control ++;
|
skip_control ++;
|
||||||
|
|
@ -5562,6 +5663,7 @@ inp_poly_err(struct line *card)
|
||||||
} else if (skip_control > 0) {
|
} else if (skip_control > 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the fourth token in a controlled source line and exit,
|
/* get the fourth token in a controlled source line and exit,
|
||||||
if it is 'poly' */
|
if it is 'poly' */
|
||||||
if ((ciprefix("e", curr_line)) || (ciprefix("g", curr_line)) ||
|
if ((ciprefix("e", curr_line)) || (ciprefix("g", curr_line)) ||
|
||||||
|
|
@ -5581,26 +5683,36 @@ inp_poly_err(struct line *card)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tprint(struct line *t)
|
tprint(struct line *t)
|
||||||
{
|
{
|
||||||
/*debug: print into file*/
|
/*debug: print into file*/
|
||||||
FILE *fd = fopen("tprint-out.txt", "w");
|
FILE *fd = fopen("tprint-out.txt", "w");
|
||||||
|
|
||||||
for (; t; t = t->li_next)
|
for (; t; t = t->li_next)
|
||||||
fprintf(fd, "%d %d %s\n", t->li_linenum_orig, t->li_linenum, t->li_line);
|
fprintf(fd, "%d %d %s\n", t->li_linenum_orig, t->li_linenum, t->li_line);
|
||||||
|
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* prepare .if and .elseif for numparam
|
/* prepare .if and .elseif for numparam
|
||||||
.if(expression) --> .if{expression} */
|
.if(expression) --> .if{expression} */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
inp_dot_if(struct line *card)
|
inp_dot_if(struct line *card)
|
||||||
{
|
{
|
||||||
for (; card; card = card->li_next) {
|
for (; card; card = card->li_next) {
|
||||||
|
|
||||||
char *curr_line = card->li_line;
|
char *curr_line = card->li_line;
|
||||||
|
|
||||||
if (*curr_line == '*')
|
if (*curr_line == '*')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ciprefix(".if", curr_line) || ciprefix(".elseif", curr_line)) {
|
if (ciprefix(".if", curr_line) || ciprefix(".elseif", curr_line)) {
|
||||||
char* firstbr = strchr(curr_line, '(');
|
char* firstbr = strchr(curr_line, '(');
|
||||||
char* lastbr = strrchr(curr_line, ')');
|
char* lastbr = strrchr(curr_line, ')');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue