From e9d37d063715e813757ad56d5053a14bba24a9a4 Mon Sep 17 00:00:00 2001 From: rlar Date: Sun, 14 Dec 2014 21:58:50 +0100 Subject: [PATCH] inpcom.c, cleanup `inp_fix_subckt()', simplify list concatenation --- src/frontend/inpcom.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 9bd35fb04..8d1c3f191 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -2118,9 +2118,8 @@ find_name(struct names *p, char *name) static char* inp_fix_subckt(struct names *subckt_w_params, char *s) { - struct line *head = NULL, *start_card = NULL, *end_card = NULL, *prev_card = NULL, *c = NULL; + struct line *head = NULL, *first_param_card = NULL, *last_param_card = NULL, *c = NULL; char *equal, *beg, *buffer, *ptr1, *ptr2, *new_str = NULL; - int num_params = 0, i = 0; equal = strchr(s, '='); if (equal && !strstr(s, "params:")) { @@ -2159,24 +2158,22 @@ inp_fix_subckt(struct names *subckt_w_params, char *s) beg = ptr2; - end_card = xx_new_line(NULL, copy_substring(ptr1, ptr2), 0, 0); + c = xx_new_line(NULL, copy_substring(ptr1, ptr2), 0, 0); - if (start_card == NULL) - head->li_next = start_card = end_card; + if (last_param_card) + last_param_card->li_next = c; else - prev_card->li_next = end_card; + first_param_card = c; - prev_card = end_card; - num_params++; + last_param_card = c; } /* now sort parameters in order of dependencies */ - head->li_next = NULL; - inp_sort_params(start_card, head, NULL, NULL); + inp_sort_params(first_param_card, head, NULL, NULL); /* create new ordered parameter string for subckt call */ c = head->li_next; tfree(head); - for (i = 0; i < num_params && c != NULL; i++) { + for (;c != NULL;) { if (new_str == NULL) { new_str = strdup(c->li_line); } else {