From 05434cb5e4bf8fbc7b80e08bff4fc7f68d19aefa Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Fri, 14 Feb 2025 13:32:17 +0100 Subject: [PATCH] fix @spice_get_*_*(...) regex --- src/token.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/token.c b/src/token.c index 635d2a8f..24149633 100644 --- a/src/token.c +++ b/src/token.c @@ -3826,11 +3826,11 @@ const char *translate(int inst, const char* s) #ifdef __unix__ if(!get_sp_cur) { get_sp_cur = my_malloc(_ALLOC_ID_, sizeof(regex_t)); - /* @spice_get_current_param(...) or @spice_get_modelparam_param(...) */ + /* @spice_get_current_(...) or @spice_get_modelparam_(...) */ /* @spice_get_current(...) or @spice_get_modelparam(...) */ - /* @spice_get_modelvoltage(...) or @spice_get_modelvoltage_param(...) */ + /* @spice_get_modelvoltage(...) or @spice_get_modelvoltage_(...) */ regcomp(get_sp_cur, - "^@spice_get_(current|modelparam|modelvoltage)([_a-zA-Z][a-zA-Z0-9_]*)*\\(", REG_NOSUB | REG_EXTENDED); + "^@spice_get_(current|modelparam|modelvoltage)(_[a-zA-Z][a-zA-Z0-9_]*)*\\(", REG_NOSUB | REG_EXTENDED); } #endif @@ -4158,16 +4158,16 @@ const char *translate(int inst, const char* s) } } } - /* @spice_get_current(...) or @spice_get_current_param(...) - * @spice_get_modelparam(...) or @spice_get_modelparam_param(...) - * @spice_get_modelvoltage(...) or @spice_get_modelvoltage_param(...) + /* @spice_get_current(...) or @spice_get_current_(...) + * @spice_get_modelparam(...) or @spice_get_modelparam_(...) + * @spice_get_modelvoltage(...) or @spice_get_modelvoltage_(...) * - * Only @spice_get_current(...) and @spice_get_current_param(...) are processed + * Only @spice_get_current(...) and @spice_get_current_(...) are processed * the other types are ignored */ #ifdef __unix__ else if(!regexec(get_sp_cur, token, 0 , NULL, 0) ) # else - else if ((win_regexec(NULL/*options*/, "^@spice_get_(current|modelparam|modelvoltage)([_a-zA-Z][a-zA-Z0-9_]*)*\\(", token))) + else if ((win_regexec(NULL/*options*/, "^@spice_get_(current|modelparam|modelvoltage)(_[a-zA-Z][a-zA-Z0-9_]*)*\\(", token))) #endif { int start_level; /* hierarchy level where waves were loaded */ @@ -4194,7 +4194,8 @@ const char *translate(int inst, const char* s) n = sscanf(token + 19, "%[^)]", dev); } else { param = my_malloc(_ALLOC_ID_, tmp); - n = sscanf(token, "@spice_get_current_%s(%[^)]", param, dev); + n = sscanf(token, "@spice_get_current_%[^(](%[^)]", param, dev); + dbg(1, "token=%s, param=%s, dev=%s\n", token, param, dev); if(n < 2) { my_free(_ALLOC_ID_, ¶m); n = sscanf(token, "@spice_get_current[^(](%[^)]", dev); @@ -4219,6 +4220,7 @@ const char *translate(int inst, const char* s) my_snprintf(fqdev, len, "i(@%c.%s%s.%s[%s])", prefix, path, instname, dev, param ? param : "ic"); } else if(prefix == 'd' || prefix == 'm') { my_snprintf(fqdev, len, "i(@%c.%s%s.%s[%s])", prefix, path, instname, dev, param ? param : "id"); + dbg(1, "translate(): fqdev=%s\n", fqdev); } else if(prefix == 'i') { my_snprintf(fqdev, len, "i(@%c.%s%s.%s[current])", prefix, path, instname, dev); } else {