subckt.c, introduce new function inp_deckcopy_oc()
copy a deck without li_actual, without comment lines without .control section
This commit is contained in:
parent
ca2af5b7b9
commit
8c8a236fa1
|
|
@ -714,6 +714,54 @@ inp_deckcopy(struct line *deck) {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Copy a deck, without the li_actual lines, without comment lines, and
|
||||
* without .control section(s).
|
||||
* First line is always copied (except being .control).
|
||||
*/
|
||||
struct line *
|
||||
inp_deckcopy_oc(struct line *deck)
|
||||
{
|
||||
struct line *d = NULL, *nd = NULL;
|
||||
int skip_control = 0;
|
||||
|
||||
while (deck) {
|
||||
/* exclude any command inside .control ... .endc */
|
||||
if (ciprefix(".control", deck->li_line)) {
|
||||
skip_control++;
|
||||
deck = deck->li_next;
|
||||
continue;
|
||||
}
|
||||
else if (ciprefix(".endc", deck->li_line)) {
|
||||
skip_control--;
|
||||
deck = deck->li_next;
|
||||
continue;
|
||||
}
|
||||
else if (skip_control > 0) {
|
||||
deck = deck->li_next;
|
||||
continue;
|
||||
}
|
||||
if (nd) {
|
||||
d->li_next = TMALLOC(struct line, 1);
|
||||
d = d->li_next;
|
||||
}
|
||||
else {
|
||||
nd = d = TMALLOC(struct line, 1);
|
||||
}
|
||||
d->li_linenum = deck->li_linenum;
|
||||
d->li_line = copy(deck->li_line);
|
||||
if (deck->li_error)
|
||||
d->li_error = copy(deck->li_error);
|
||||
d->li_actual = NULL;
|
||||
deck = deck->li_next;
|
||||
while (deck && *(deck->li_line) == '*')
|
||||
deck = deck->li_next;
|
||||
}
|
||||
|
||||
return (nd);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------
|
||||
* struct bxx_buffer,
|
||||
* a string assembly facility.
|
||||
|
|
|
|||
|
|
@ -8,5 +8,6 @@
|
|||
|
||||
struct line * inp_subcktexpand(struct line *deck);
|
||||
struct line * inp_deckcopy(struct line *deck);
|
||||
struct line * inp_deckcopy_oc(struct line *deck);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue