From aa36cbb89792da9e9ed91460e01362a3e628ccdf Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Thu, 9 Jan 2025 15:35:35 +0100 Subject: [PATCH] @path expansion in translate(): remove path components above the level where raw file (if any) was loaded; added @spice_get_current in bsource.sym --- src/token.c | 11 +++++++++++ xschem_library/devices/bsource.sym | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/token.c b/src/token.c index f41c01e7..d66831dd 100644 --- a/src/token.c +++ b/src/token.c @@ -3739,6 +3739,15 @@ const char *translate(int inst, const char* s) result_pos+=tmp; } else if(strcmp(token,"@path")==0) { const char *path = xctx->sch_path[xctx->currsch] + 1; + int start_level = sch_waves_loaded(), skip = 0; + if(start_level == -1) start_level = 0; + + /* skip path components that are above the level where raw file was loaded */ + while(*path && skip < start_level) { + if(*path == '.') skip++; + ++path; + } + tmp=strlen(path); STR_ALLOC(&result, tmp + result_pos, &size); memcpy(result+result_pos, path, tmp+1); @@ -4367,11 +4376,13 @@ const char *translate2(Lcc *lcc, int level, char* s) } else if(strcmp(token,"@path")==0) { char *path = NULL; + here(level); my_strdup2(_ALLOC_ID_, &path, "@path@name\\."); if(level > 1) { /* add parent LCC instance names (X1, Xinv etc) */ int i; for(i = 1; i