|
|
@ -174,6 +174,15 @@ xx_new_line(struct line *next, char *line, int linenum, int linenum_orig) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* insert a new card, just behind the given card */ |
|
|
|
|
|
static struct line * |
|
|
|
|
|
insert_new_line(struct line *card, char *line, int linenum, int linenum_orig) |
|
|
|
|
|
{ |
|
|
|
|
|
card = card->li_next = xx_new_line(card->li_next, line, linenum, linenum_orig); |
|
|
|
|
|
return card; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct library * |
|
|
static struct library * |
|
|
new_lib(void) |
|
|
new_lib(void) |
|
|
{ |
|
|
{ |
|
|
@ -925,7 +934,7 @@ inp_read(FILE *fp, int call_depth, char *dir_name, bool comfile, bool intfile) |
|
|
comfile = TRUE; |
|
|
comfile = TRUE; |
|
|
|
|
|
|
|
|
if (call_depth == 0 && !comfile) { |
|
|
if (call_depth == 0 && !comfile) { |
|
|
cc->li_next = xx_new_line(cc->li_next, copy(".global gnd"), 1, 0); |
|
|
|
|
|
|
|
|
insert_new_line(cc, copy(".global gnd"), 1, 0); |
|
|
|
|
|
|
|
|
if (inp_compat_mode == COMPATMODE_ALL || |
|
|
if (inp_compat_mode == COMPATMODE_ALL || |
|
|
inp_compat_mode == COMPATMODE_HS || |
|
|
inp_compat_mode == COMPATMODE_HS || |
|
|
@ -942,7 +951,7 @@ inp_read(FILE *fp, int call_depth, char *dir_name, bool comfile, bool intfile) |
|
|
|
|
|
|
|
|
if (call_depth == 0 && !comfile) |
|
|
if (call_depth == 0 && !comfile) |
|
|
if (found_end == TRUE) |
|
|
if (found_end == TRUE) |
|
|
end = end->li_next = xx_new_line(end->li_next, copy(".end"), line_number++, line_number_orig++); |
|
|
|
|
|
|
|
|
end = insert_new_line(end, copy(".end"), line_number++, line_number_orig++); |
|
|
|
|
|
|
|
|
/* Replace first line with the new title, if available */ |
|
|
/* Replace first line with the new title, if available */ |
|
|
if (call_depth == 0 && !comfile && new_title) { |
|
|
if (call_depth == 0 && !comfile && new_title) { |
|
|
@ -1346,8 +1355,8 @@ inp_chk_for_multi_in_vcvs(struct line *c, int *line_number) |
|
|
tfree(xy_values2[1]); |
|
|
tfree(xy_values2[1]); |
|
|
|
|
|
|
|
|
*c->li_line = '*'; |
|
|
*c->li_line = '*'; |
|
|
c = c->li_next = xx_new_line(c->li_next, m_instance, (*line_number)++, 0); |
|
|
|
|
|
c = c->li_next = xx_new_line(c->li_next, m_model, (*line_number)++, 0); |
|
|
|
|
|
|
|
|
c = insert_new_line(c, m_instance, (*line_number)++, 0); |
|
|
|
|
|
c = insert_new_line(c, m_model, (*line_number)++, 0); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -1394,13 +1403,13 @@ inp_add_control_section(struct line *deck, int *line_number) |
|
|
found_control = FALSE; |
|
|
found_control = FALSE; |
|
|
|
|
|
|
|
|
if (!found_run) { |
|
|
if (!found_run) { |
|
|
prev_card = prev_card->li_next = xx_new_line(prev_card->li_next, copy("run"), (*line_number)++, 0); |
|
|
|
|
|
|
|
|
prev_card = insert_new_line(prev_card, copy("run"), (*line_number)++, 0); |
|
|
found_run = TRUE; |
|
|
found_run = TRUE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (cp_getvar("rawfile", CP_STRING, rawfile)) { |
|
|
if (cp_getvar("rawfile", CP_STRING, rawfile)) { |
|
|
line = tprintf("write %s", rawfile); |
|
|
line = tprintf("write %s", rawfile); |
|
|
prev_card = prev_card->li_next = xx_new_line(prev_card->li_next, line, (*line_number)++, 0); |
|
|
|
|
|
|
|
|
prev_card = insert_new_line(prev_card, line, (*line_number)++, 0); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -1410,19 +1419,19 @@ inp_add_control_section(struct line *deck, int *line_number) |
|
|
// check if need to add control section |
|
|
// check if need to add control section |
|
|
if (!found_run && found_end) { |
|
|
if (!found_run && found_end) { |
|
|
|
|
|
|
|
|
deck->li_next = xx_new_line(deck->li_next, copy(".endc"), (*line_number)++, 0); |
|
|
|
|
|
|
|
|
insert_new_line(deck, copy(".endc"), (*line_number)++, 0); |
|
|
|
|
|
|
|
|
if (cp_getvar("rawfile", CP_STRING, rawfile)) { |
|
|
if (cp_getvar("rawfile", CP_STRING, rawfile)) { |
|
|
line = tprintf("write %s", rawfile); |
|
|
line = tprintf("write %s", rawfile); |
|
|
deck->li_next = xx_new_line(deck->li_next, line, (*line_number)++, 0); |
|
|
|
|
|
|
|
|
insert_new_line(deck, line, (*line_number)++, 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (op_line) |
|
|
if (op_line) |
|
|
deck->li_next = xx_new_line(deck->li_next, copy(op_line), (*line_number)++, 0); |
|
|
|
|
|
|
|
|
insert_new_line(deck, copy(op_line), (*line_number)++, 0); |
|
|
|
|
|
|
|
|
deck->li_next = xx_new_line(deck->li_next, copy("run"), (*line_number)++, 0); |
|
|
|
|
|
|
|
|
insert_new_line(deck, copy("run"), (*line_number)++, 0); |
|
|
|
|
|
|
|
|
deck->li_next = xx_new_line(deck->li_next, copy(".control"), (*line_number)++, 0); |
|
|
|
|
|
|
|
|
insert_new_line(deck, copy(".control"), (*line_number)++, 0); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -2420,7 +2429,7 @@ expand_section_ref(struct line *c, char *dir_name) |
|
|
{ |
|
|
{ |
|
|
struct line *t = section_def; |
|
|
struct line *t = section_def; |
|
|
for (; t; t=t->li_next) { |
|
|
for (; t; t=t->li_next) { |
|
|
c = c->li_next = xx_new_line(c->li_next, copy(t->li_line), t->li_linenum, t->li_linenum_orig); |
|
|
|
|
|
|
|
|
c = insert_new_line(c, copy(t->li_line), t->li_linenum, t->li_linenum_orig); |
|
|
if (t == section_def) { |
|
|
if (t == section_def) { |
|
|
c->li_line[0] = '*'; |
|
|
c->li_line[0] = '*'; |
|
|
c->li_line[1] = '<'; |
|
|
c->li_line[1] = '<'; |
|
|
@ -4039,7 +4048,7 @@ inp_split_multi_param_lines(struct line *card, int line_num) |
|
|
*(card->li_line) = '*'; |
|
|
*(card->li_line) = '*'; |
|
|
// insert new param lines immediately after current line |
|
|
// insert new param lines immediately after current line |
|
|
for (i = 0; i < counter; i++) |
|
|
for (i = 0; i < counter; i++) |
|
|
card = card->li_next = xx_new_line(card->li_next, array[i], line_num++, 0); |
|
|
|
|
|
|
|
|
card = insert_new_line(card, array[i], line_num++, 0); |
|
|
|
|
|
|
|
|
tfree(array); |
|
|
tfree(array); |
|
|
} |
|
|
} |
|
|
@ -4344,7 +4353,7 @@ inp_compat(struct line *card) |
|
|
*(card->li_line) = '*'; |
|
|
*(card->li_line) = '*'; |
|
|
// insert new B source line immediately after current line |
|
|
// insert new B source line immediately after current line |
|
|
for (i = 0; i < 2; i++) |
|
|
for (i = 0; i < 2; i++) |
|
|
card = card->li_next = xx_new_line(card->li_next, ckt_array[i], 0, 0); |
|
|
|
|
|
|
|
|
card = insert_new_line(card, ckt_array[i], 0, 0); |
|
|
|
|
|
|
|
|
tfree(firstno); |
|
|
tfree(firstno); |
|
|
tfree(lastlastno); |
|
|
tfree(lastlastno); |
|
|
@ -4382,7 +4391,7 @@ inp_compat(struct line *card) |
|
|
*(card->li_line) = '*'; |
|
|
*(card->li_line) = '*'; |
|
|
// insert new B source line immediately after current line |
|
|
// insert new B source line immediately after current line |
|
|
for (i = 0; i < 2; i++) |
|
|
for (i = 0; i < 2; i++) |
|
|
card = card->li_next = xx_new_line(card->li_next, ckt_array[i], 0, 0); |
|
|
|
|
|
|
|
|
card = insert_new_line(card, ckt_array[i], 0, 0); |
|
|
|
|
|
|
|
|
tfree(title_tok); |
|
|
tfree(title_tok); |
|
|
tfree(node1); |
|
|
tfree(node1); |
|
|
@ -4502,7 +4511,7 @@ inp_compat(struct line *card) |
|
|
*(card->li_line) = '*'; |
|
|
*(card->li_line) = '*'; |
|
|
// insert new B source line immediately after current line |
|
|
// insert new B source line immediately after current line |
|
|
for (i = 0; i < 2; i++) |
|
|
for (i = 0; i < 2; i++) |
|
|
card = card->li_next = xx_new_line(card->li_next, ckt_array[i], 0, 0); |
|
|
|
|
|
|
|
|
card = insert_new_line(card, ckt_array[i], 0, 0); |
|
|
|
|
|
|
|
|
tfree(firstno); |
|
|
tfree(firstno); |
|
|
tfree(lastlastno); |
|
|
tfree(lastlastno); |
|
|
@ -4552,7 +4561,7 @@ inp_compat(struct line *card) |
|
|
*(card->li_line) = '*'; |
|
|
*(card->li_line) = '*'; |
|
|
// insert new B source line immediately after current line |
|
|
// insert new B source line immediately after current line |
|
|
for (i = 0; i < 2; i++) |
|
|
for (i = 0; i < 2; i++) |
|
|
card = card->li_next = xx_new_line(card->li_next, ckt_array[i], 0, 0); |
|
|
|
|
|
|
|
|
card = insert_new_line(card, ckt_array[i], 0, 0); |
|
|
|
|
|
|
|
|
tfree(title_tok); |
|
|
tfree(title_tok); |
|
|
tfree(m_token); |
|
|
tfree(m_token); |
|
|
@ -4598,7 +4607,7 @@ inp_compat(struct line *card) |
|
|
*(card->li_line) = '*'; |
|
|
*(card->li_line) = '*'; |
|
|
// insert new three lines immediately after current line |
|
|
// insert new three lines immediately after current line |
|
|
for (i = 0; i < 3; i++) |
|
|
for (i = 0; i < 3; i++) |
|
|
card = card->li_next = xx_new_line(card->li_next, ckt_array[i], 0, 0); |
|
|
|
|
|
|
|
|
card = insert_new_line(card, ckt_array[i], 0, 0); |
|
|
|
|
|
|
|
|
tfree(title_tok); |
|
|
tfree(title_tok); |
|
|
tfree(vnamstr); |
|
|
tfree(vnamstr); |
|
|
@ -4644,7 +4653,7 @@ inp_compat(struct line *card) |
|
|
*(card->li_line) = '*'; |
|
|
*(card->li_line) = '*'; |
|
|
// insert new three lines immediately after current line |
|
|
// insert new three lines immediately after current line |
|
|
for (i = 0; i < 3; i++) |
|
|
for (i = 0; i < 3; i++) |
|
|
card = card->li_next = xx_new_line(card->li_next, ckt_array[i], 0, 0); |
|
|
|
|
|
|
|
|
card = insert_new_line(card, ckt_array[i], 0, 0); |
|
|
|
|
|
|
|
|
tfree(title_tok); |
|
|
tfree(title_tok); |
|
|
tfree(vnamstr); |
|
|
tfree(vnamstr); |
|
|
@ -4719,7 +4728,7 @@ inp_compat(struct line *card) |
|
|
// comment out current old R line |
|
|
// comment out current old R line |
|
|
*(card->li_line) = '*'; |
|
|
*(card->li_line) = '*'; |
|
|
// insert new B source line immediately after current line |
|
|
// insert new B source line immediately after current line |
|
|
card = card->li_next = xx_new_line(card->li_next, xline, 0, 0); |
|
|
|
|
|
|
|
|
card = insert_new_line(card, xline, 0, 0); |
|
|
|
|
|
|
|
|
tfree(title_tok); |
|
|
tfree(title_tok); |
|
|
tfree(node1); |
|
|
tfree(node1); |
|
|
@ -4798,7 +4807,7 @@ inp_compat(struct line *card) |
|
|
*(card->li_line) = '*'; |
|
|
*(card->li_line) = '*'; |
|
|
// insert new B source line immediately after current line |
|
|
// insert new B source line immediately after current line |
|
|
for (i = 0; i < 3; i++) |
|
|
for (i = 0; i < 3; i++) |
|
|
card = card->li_next = xx_new_line(card->li_next, ckt_array[i], 0, 0); |
|
|
|
|
|
|
|
|
card = insert_new_line(card, ckt_array[i], 0, 0); |
|
|
|
|
|
|
|
|
tfree(title_tok); |
|
|
tfree(title_tok); |
|
|
tfree(node1); |
|
|
tfree(node1); |
|
|
@ -4878,7 +4887,7 @@ inp_compat(struct line *card) |
|
|
*(card->li_line) = '*'; |
|
|
*(card->li_line) = '*'; |
|
|
// insert new B source line immediately after current line |
|
|
// insert new B source line immediately after current line |
|
|
for (i = 0; i < 3; i++) |
|
|
for (i = 0; i < 3; i++) |
|
|
card = card->li_next = xx_new_line(card->li_next, ckt_array[i], 0, 0); |
|
|
|
|
|
|
|
|
card = insert_new_line(card, ckt_array[i], 0, 0); |
|
|
|
|
|
|
|
|
tfree(title_tok); |
|
|
tfree(title_tok); |
|
|
tfree(node1); |
|
|
tfree(node1); |
|
|
@ -5021,7 +5030,7 @@ inp_compat(struct line *card) |
|
|
card->li_line = inp_remove_ws(curr_line); |
|
|
card->li_line = inp_remove_ws(curr_line); |
|
|
// insert new B source line immediately after current line |
|
|
// insert new B source line immediately after current line |
|
|
for (ii = paui; ii < pai; ii++) |
|
|
for (ii = paui; ii < pai; ii++) |
|
|
card = card->li_next = xx_new_line(card->li_next, ckt_array[ii], 0, 0); |
|
|
|
|
|
|
|
|
card = insert_new_line(card, ckt_array[ii], 0, 0); |
|
|
|
|
|
|
|
|
paui = pai; |
|
|
paui = pai; |
|
|
} else if ((ciprefix(".save", curr_line)) || |
|
|
} else if ((ciprefix(".save", curr_line)) || |
|
|
@ -5115,7 +5124,7 @@ inp_compat(struct line *card) |
|
|
// *(ckt_array[0]) = '*'; |
|
|
// *(ckt_array[0]) = '*'; |
|
|
// insert new B source line immediately after current line |
|
|
// insert new B source line immediately after current line |
|
|
for (ii = paui; ii < pai; ii++) |
|
|
for (ii = paui; ii < pai; ii++) |
|
|
card = card->li_next = xx_new_line(card->li_next, ckt_array[ii], 0, 0); |
|
|
|
|
|
|
|
|
card = insert_new_line(card, ckt_array[ii], 0, 0); |
|
|
|
|
|
|
|
|
paui = pai; |
|
|
paui = pai; |
|
|
// continue; |
|
|
// continue; |
|
|
@ -5211,7 +5220,7 @@ inp_bsource_compat(struct line *card) |
|
|
*(card->li_line) = '*'; |
|
|
*(card->li_line) = '*'; |
|
|
// insert new B source line immediately after current line |
|
|
// insert new B source line immediately after current line |
|
|
/* Copy old line numbers into new B source line */ |
|
|
/* Copy old line numbers into new B source line */ |
|
|
card = card->li_next = xx_new_line(card->li_next, final_str, card->li_linenum, card->li_linenum_orig); |
|
|
|
|
|
|
|
|
card = insert_new_line(card, final_str, card->li_linenum, card->li_linenum_orig); |
|
|
|
|
|
|
|
|
tfree(new_str); |
|
|
tfree(new_str); |
|
|
} /* end of if 'b' */ |
|
|
} /* end of if 'b' */ |
|
|
@ -5537,8 +5546,8 @@ inp_add_series_resistor(struct line *deck) |
|
|
*(card->li_line) = '*'; |
|
|
*(card->li_line) = '*'; |
|
|
|
|
|
|
|
|
// insert new new L and R lines immediately after current line |
|
|
// insert new new L and R lines immediately after current line |
|
|
card = card->li_next = xx_new_line(card->li_next, newL, 0, 0); |
|
|
|
|
|
card = card->li_next = xx_new_line(card->li_next, newR, 0, 0); |
|
|
|
|
|
|
|
|
card = insert_new_line(card, newL, 0, 0); |
|
|
|
|
|
card = insert_new_line(card, newR, 0, 0); |
|
|
|
|
|
|
|
|
tfree(title_tok); |
|
|
tfree(title_tok); |
|
|
tfree(node1); |
|
|
tfree(node1); |
|
|
@ -5575,8 +5584,7 @@ subckt_params_to_param(struct line *card) |
|
|
/* card->li_line ends with subcircuit name */ |
|
|
/* card->li_line ends with subcircuit name */ |
|
|
cut_line[-1] = '\0'; |
|
|
cut_line[-1] = '\0'; |
|
|
/* insert new_line after card->li_line */ |
|
|
/* insert new_line after card->li_line */ |
|
|
card->li_next = xx_new_line(card->li_next, new_line, |
|
|
|
|
|
card->li_linenum + 1, 0); |
|
|
|
|
|
|
|
|
insert_new_line(card, new_line, card->li_linenum + 1, 0); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -5886,7 +5894,7 @@ inp_fix_temper_in_param(struct line *deck) |
|
|
tfree(funcbody); |
|
|
tfree(funcbody); |
|
|
} else { |
|
|
} else { |
|
|
/* Or just enter new line into deck */ |
|
|
/* Or just enter new line into deck */ |
|
|
card->li_next = xx_new_line(card->li_next, new_str, 0, card->li_linenum); |
|
|
|
|
|
|
|
|
insert_new_line(card, new_str, 0, card->li_linenum); |
|
|
*card->li_line = '*'; |
|
|
*card->li_line = '*'; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -5944,7 +5952,7 @@ inp_new_func(char *funcname, char *funcbody, struct line *card, |
|
|
new_str = tprintf(".func %s() %s", funcname, funcbody); |
|
|
new_str = tprintf(".func %s() %s", funcname, funcbody); |
|
|
|
|
|
|
|
|
*card->li_line = '*'; |
|
|
*card->li_line = '*'; |
|
|
card->li_next = xx_new_line(card->li_next, new_str, 0, card->li_linenum); |
|
|
|
|
|
|
|
|
insert_new_line(card, new_str, 0, card->li_linenum); |
|
|
|
|
|
|
|
|
return f; |
|
|
return f; |
|
|
} |
|
|
} |
|
|
|