From d875687752f66da5fce5610ac13a41c174fc7173 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Sat, 7 Sep 2013 12:13:51 +0200 Subject: [PATCH] inpcom.c: `rewrite expand_section_references()' --- src/frontend/inpcom.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 707417192..1ae8b2ef8 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -2456,22 +2456,28 @@ expand_section_references(struct line *c, int call_depth, char *dir_name) /* insert the library section definition into `c' */ { - struct line *t = inp_deckcopy(section_def); + struct line *corig = c; + struct line *cend = c; struct line *rest = c->li_next; - c->li_next = t; - t->li_line[0] = '*'; - t->li_line[1] = '<'; - for (; t; t=t->li_next) + struct line *t = section_def; + cend = c->li_next = xx_new_line(NULL, copy(t->li_line), t->li_linenum, t->li_linenum_orig); + cend->li_line[0] = '*'; + cend->li_line[1] = '<'; + t = t->li_next; + for (; t; t=t->li_next) { + cend->li_next = xx_new_line(NULL, copy(t->li_line), t->li_linenum, t->li_linenum_orig); + cend = cend->li_next; if(ciprefix(".endl", t->li_line)) break; + } if (!t) { fprintf(stderr, "ERROR, .endl not found\n"); controlled_exit(EXIT_FAILURE); } - t->li_line[0] = '*'; - t->li_line[1] = '>'; - line_free_x(t->li_next, TRUE); - t->li_next = rest; + cend->li_line[0] = '*'; + cend->li_line[1] = '>'; + c = corig; + cend->li_next = rest; } *line = '*'; /* comment out .lib line */