From 01fe243032a3957ef8489899fb5f8e56aa2f0b15 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Sun, 2 Jun 2013 12:03:07 +0200 Subject: [PATCH] inpcom.c: multiplier m for behavioral g source --- src/frontend/inpcom.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index d3ceac8ac..1444be05d 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -4487,6 +4487,8 @@ inp_compat(struct line *card) BGxxx int1 0 V = {equation} */ if ((str_ptr = strstr(curr_line, "cur")) != NULL) { + char *m_ptr, *m_token; + int m_len = 0; cut_line = curr_line; /* title and nodes */ title_tok = gettok(&cut_line); @@ -4498,12 +4500,23 @@ inp_compat(struct line *card) fprintf(stderr, "ERROR: mal formed G line: %s\n", curr_line); controlled_exit(EXIT_FAILURE); } + /* find multiplier m at end of line */ + m_ptr = strstr(cut_line, "m="); + if (m_ptr) { + m_token = copy(m_ptr); + *m_ptr = '\0'; + } + else + m_token = copy("1"); + m_len = strlen(m_token); // Gxxx n1 n2 int1 0 1 + // or + // Gxxx n1 n2 int1 0 m='expr' xlen = 2*strlen(title_tok) + strlen(node1) + strlen(node2) - + 20 - 4*2 + 1; + + 20 - 4*2 + m_len; ckt_array[0] = TMALLOC(char, xlen); - sprintf(ckt_array[0], "%s %s %s %s_int1 0 1", - title_tok, node1, node2, title_tok); + sprintf(ckt_array[0], "%s %s %s %s_int1 0 %s", + title_tok, node1, node2, title_tok, m_token); // BGxxx int1 0 V = {equation} xlen = 2*strlen(title_tok) + strlen(str_ptr) + 20 - 3*2 + 1; @@ -4537,6 +4550,7 @@ inp_compat(struct line *card) param_beg = param_end = NULL; tfree(title_tok); + tfree(m_token); tfree(node1); tfree(node2); }