From 35354e8fe34ccaf4c071e7059d09f8a810e76f56 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Fri, 12 May 2023 01:29:38 +0200 Subject: [PATCH] fix: check for NULL type attribute in get_sch_from_sym(). Fix web schematic navigation (descend and return) in load_schematic() --- src/actions.c | 2 +- src/draw.c | 2 +- src/save.c | 14 ++++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/actions.c b/src/actions.c index 7adb91e0..1b77f038 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1426,7 +1426,7 @@ void get_sch_from_sym(char *filename, xSymbol *sym, int inst) strstr(xctx->current_dirname, "https://") == xctx->current_dirname) { web_url = 1; } - dbg(1, "get_sch_from_sym(): symbol %s inst=%d\n", sym->name, inst); + dbg(1, "get_sch_from_sym(): symbol %s inst=%d web_url=%d\n", sym->name, inst, web_url); if(inst >= 0) my_strdup(_ALLOC_ID_, &str_tmp, get_tok_value(xctx->inst[inst].prop_ptr, "schematic", 2)); if(!str_tmp) my_strdup2(_ALLOC_ID_, &str_tmp, get_tok_value(sym->prop_ptr, "schematic", 2)); if(str_tmp[0]) { /* schematic attribute in symbol or instance was given */ diff --git a/src/draw.c b/src/draw.c index ac969a17..b288aac8 100644 --- a/src/draw.c +++ b/src/draw.c @@ -438,7 +438,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, if(xctx->inst[n].ptr == -1) return; if( layer == 0) { char *type = xctx->sym[xctx->inst[n].ptr].type; - if( strcmp(type, "launcher") && strcmp(type, "logo") && + if( type && strcmp(type, "launcher") && strcmp(type, "logo") && strcmp(type, "probe") && strcmp(type, "architecture") && strcmp(type, "noconn")) { if( diff --git a/src/save.c b/src/save.c index 6f01e34f..3e1fcb0a 100644 --- a/src/save.c +++ b/src/save.c @@ -2445,7 +2445,7 @@ void load_schematic(int load_symbols, const char *fname, int reset_undo, int ale int generator = 0; if(is_generator(fname)) generator = 1; my_strncpy(name, fname, S(name)); - + dbg(0, "load_schematic(): fname=%s\n", fname); /* remote web object specified */ if(strstr(fname , "http://") == fname || strstr(fname , "https://") == fname) { @@ -2468,17 +2468,18 @@ void load_schematic(int load_symbols, const char *fname, int reset_undo, int ale char sympath[PATH_MAX]; my_snprintf(sympath, S(sympath), "%s/xschem_web", tclgetvar("XSCHEM_TMP_DIR")); /* fname does not begin with $XSCHEM_TMP_DIR/xschem_web and fname does not exist */ - if(strstr(fname, sympath) != fname && stat(fname, &buf)) { + + if(strstr(fname, sympath) != fname /* && stat(fname, &buf)*/) { my_snprintf(msg, S(msg), "get_directory {%s}", fname); my_strncpy(xctx->current_dirname, tcleval(msg), S(xctx->current_dirname)); - } + } + /* local file name */ my_strncpy(xctx->sch[xctx->currsch], fname, S(xctx->sch[xctx->currsch])); /* local relative reference */ my_strncpy(xctx->current_name, rel_sym_path(fname), S(xctx->current_name)); - /* local file specified and not coming from web url */ - } else { - /* if name is /some/path/. remove /. at end */ + } else { /* local file specified and not coming from web url */ + /* build current_dirname by stripping off last filename from url */ my_snprintf(msg, S(msg), "get_directory {%s}", fname); my_strncpy(xctx->current_dirname, tcleval(msg), S(xctx->current_dirname)); /* local file name */ @@ -2486,6 +2487,7 @@ void load_schematic(int load_symbols, const char *fname, int reset_undo, int ale /* local relative reference */ my_strncpy(xctx->current_name, rel_sym_path(fname), S(xctx->current_name)); } + dbg(1, "load_schematic(): opening file for loading:%s, fname=%s\n", name, fname); dbg(1, "load_schematic(): sch[currsch]=%s\n", xctx->sch[xctx->currsch]); if(!name[0]) return; /* empty filename */