From c485cd4b8bf724a2dfd8337cb1805f6b7e22bbe6 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Sun, 2 Jun 2013 13:23:57 +0200 Subject: [PATCH] inpcom.c: G source, fix a bug and add `m' to TABLE --- src/frontend/inpcom.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index f706df581..b87359589 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -4311,6 +4311,7 @@ inp_compat(struct line *card) */ if ((str_ptr = strstr(curr_line, "table")) != NULL) { char *expression, *firstno, *ffirstno, *secondno, *midline, *lastno, *lastlastno; + char *m_ptr, *m_token; double fnumber, lnumber, delta; int nerror; cut_line = curr_line; @@ -4319,11 +4320,21 @@ inp_compat(struct line *card) node1 = gettok(&cut_line); node2 = gettok(&cut_line); // Gxxx n1 n2 int1 0 1 + // or + // Gxxx n1 n2 int1 0 m='expr' + /* find multiplier m at end of line */ + m_ptr = strstr(cut_line, "m="); + if (m_ptr) { + m_token = copy(m_ptr + 2); // get only the expression + *m_ptr = '\0'; + } + else + m_token = copy("1"); xlen = 2*strlen(title_tok) + strlen(node1) + strlen(node2) - + 20 - 4*2 + 1; + + 20 - 4*2 + strlen(m_token); 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); // get the expression str_ptr = gettok(&cut_line); /* ignore 'table' */ if (!cieq(str_ptr, "table")) { @@ -4417,6 +4428,7 @@ inp_compat(struct line *card) tfree(title_tok); tfree(node1); tfree(node2); + tfree(m_token); } /* Gxxx n1 n2 CUR = {equation} @@ -4440,7 +4452,7 @@ inp_compat(struct line *card) /* find multiplier m at end of line */ m_ptr = strstr(cut_line, "m="); if (m_ptr) { - m_token = copy(m_ptr); + m_token = copy(m_ptr + 2); //get only the expression *m_ptr = '\0'; } else