From d8eb685fcc6dfc58a8eb5c92751d30e27f77c666 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Mon, 31 Oct 2022 15:29:44 +0100 Subject: [PATCH] Preliminary fix to get_number_terminals: check for tokens with '=' to stop and get number of nodes by stepping back. --- src/frontend/inpcom.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 9699d4709..838c5d641 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -4730,9 +4730,24 @@ int get_number_terminals(char *c) break; } #ifdef OSDI - case 'a': + case 'a': /* Recognize an unknown number of nodes by stopping at tokens with '=' */ { - return 5; + i = 0; + char* cc, * ccfree; + cc = copy(c); + /* required to make m= 1 a single token m=1 */ + ccfree = cc = inp_remove_ws(cc); + /* find the first token with "off", "tnodeout", "thermal" or "=" in the line*/ + while ((i < 20) && (*cc != '\0')) { + char* inst = gettok_instance(&cc); + strncpy(nam_buf, inst, sizeof(nam_buf) - 1); + txfree(inst); + if (i > 2 && (strchr(nam_buf, '='))) + break; + i++; + } + tfree(ccfree); + return i - 2; break; } #endif