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:
h_vogt 2016-06-03 22:31:24 +02:00 committed by Holger Vogt
parent dc604c75d5
commit 464f855d1d
2 changed files with 49 additions and 0 deletions

View File

@ -710,6 +710,54 @@ inp_deckcopy(struct card *deck) {
}
/*
* Copy a deck, without the ->actualLine lines, without comment lines, and
* without .control section(s).
* First line is always copied (except being .control).
*/
struct card *
inp_deckcopy_oc(struct card *deck)
{
struct card *d = NULL, *nd = NULL;
int skip_control = 0;
while (deck) {
/* exclude any command inside .control ... .endc */
if (ciprefix(".control", deck->line)) {
skip_control++;
deck = deck->nextcard;
continue;
}
else if (ciprefix(".endc", deck->line)) {
skip_control--;
deck = deck->nextcard;
continue;
}
else if (skip_control > 0) {
deck = deck->nextcard;
continue;
}
if (nd) {
d->nextcard = TMALLOC(struct card, 1);
d = d->nextcard;
}
else {
nd = d = TMALLOC(struct card, 1);
}
d->linenum = deck->linenum;
d->line = copy(deck->line);
if (deck->error)
d->error = copy(deck->error);
d->actualLine = NULL;
deck = deck->nextcard;
while (deck && *(deck->line) == '*')
deck = deck->nextcard;
}
return (nd);
}
/*-------------------------------------------------------------------
* struct bxx_buffer,
* a string assembly facility.

View File

@ -8,5 +8,6 @@
struct card *inp_subcktexpand(struct card *deck);
struct card *inp_deckcopy(struct card *deck);
struct card *inp_deckcopy_oc(struct card *deck);
#endif