From afac3f7620a980f9a413cec4cf036c098a2d6a4d Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Thu, 13 Feb 2025 22:18:23 +0100 Subject: [PATCH] token.c: translate(): protect regex*() calls with #ifdef __unix__ --- src/token.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/token.c b/src/token.c index 418f7e44..5082c016 100644 --- a/src/token.c +++ b/src/token.c @@ -3784,7 +3784,9 @@ const char *spice_get_node(const char *token) /* if s==NULL return emty string */ const char *translate(int inst, const char* s) { + #ifdef __unix__ static regex_t *get_sp_cur = NULL; + #endif static const char *empty=""; static char *result=NULL; /* safe to keep even with multiple schematics */ size_t size=0; @@ -3809,16 +3811,19 @@ const char *translate(int inst, const char* s) if(!s && inst == -1) { if(result) my_free(_ALLOC_ID_, &result); + #ifdef __unix__ if(get_sp_cur) { regfree(get_sp_cur); get_sp_cur = NULL; } + #endif } if(!s || !xctx || !xctx->inst) { return empty; } + #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(...) */ @@ -3827,6 +3832,7 @@ const char *translate(int inst, const char* s) regcomp(get_sp_cur, "^@spice_get_(current|modelparam|modelvoltage)([_a-zA-Z][a-zA-Z0-9_]*)*\\(", REG_NOSUB | REG_EXTENDED); } + #endif sp_prefix = tclgetboolvar("spiceprefix"); @@ -4158,7 +4164,11 @@ const char *translate(int inst, const char* s) * * Only @spice_get_current(...) and @spice_get_current_param(...) are processed * the other types are ignored */ + #ifdef __unix__ else if(!regexec(get_sp_cur, token, 0 , NULL, 0) ) + # else + else if(0) /* FIXME: windows workaround for missing regex* functions */ + #endif { int start_level; /* hierarchy level where waves were loaded */ int live = tclgetboolvar("live_cursor2_backannotate");