better handling of web_urls: if already cached do not download again
This commit is contained in:
parent
1a9fddba99
commit
e0bde2cb1c
|
|
@ -1574,15 +1574,16 @@ void get_sch_from_sym(char *filename, xSymbol *sym, int inst)
|
||||||
}
|
}
|
||||||
if(sch) my_free(_ALLOC_ID_, &sch);
|
if(sch) my_free(_ALLOC_ID_, &sch);
|
||||||
|
|
||||||
/* if( strstr(xctx->current_dirname, "http://") == xctx->current_dirname ||
|
|
||||||
* strstr(xctx->current_dirname, "https://") == xctx->current_dirname) {
|
|
||||||
*/
|
|
||||||
if(web_url) {
|
if(web_url) {
|
||||||
char sympath[PATH_MAX];
|
char sympath[PATH_MAX];
|
||||||
/* download item into ${XSCHEM_TMP_DIR}/xschem_web */
|
|
||||||
tclvareval("try_download_url {", xctx->current_dirname, "} {", filename, "}", NULL);
|
/* build local cached filename of web_url */
|
||||||
/* build local file name of downloaded object and load it */
|
|
||||||
my_snprintf(sympath, S(sympath), "%s/xschem_web/%s", tclgetvar("XSCHEM_TMP_DIR"), get_cell_w_ext(filename, 0));
|
my_snprintf(sympath, S(sympath), "%s/xschem_web/%s", tclgetvar("XSCHEM_TMP_DIR"), get_cell_w_ext(filename, 0));
|
||||||
|
if(stat(sympath, &buf)) { /* not found, download */
|
||||||
|
/* download item into ${XSCHEM_TMP_DIR}/xschem_web */
|
||||||
|
tclvareval("try_download_url {", xctx->current_dirname, "} {", filename, "}", NULL);
|
||||||
|
}
|
||||||
|
/* load it */
|
||||||
my_strncpy(filename, sympath, PATH_MAX);
|
my_strncpy(filename, sympath, PATH_MAX);
|
||||||
}
|
}
|
||||||
my_free(_ALLOC_ID_, &str_tmp);
|
my_free(_ALLOC_ID_, &str_tmp);
|
||||||
|
|
|
||||||
|
|
@ -579,6 +579,20 @@ static int bus_search(const char*s)
|
||||||
return bus;
|
return bus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __unix__
|
||||||
|
static int win_regexec(const char *options, const char *pattern, char *name)
|
||||||
|
{
|
||||||
|
if (options!=NULL)
|
||||||
|
tclvareval("regexp {", options,"} {", pattern, "} {", name, "}", NULL);
|
||||||
|
else
|
||||||
|
tclvareval("regexp {", pattern, "} {", name, "}", NULL);
|
||||||
|
int ret = atoi(tclresult());
|
||||||
|
if (ret > 0)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* sel: -1 --> unselect
|
/* sel: -1 --> unselect
|
||||||
* 1 --> select
|
* 1 --> select
|
||||||
* 0 --> highlight
|
* 0 --> highlight
|
||||||
|
|
@ -649,7 +663,8 @@ int search(const char *tok, const char *val, int sub, int sel)
|
||||||
if( (!sub && !regexec(&re, str,0 , NULL, 0) ) || /* 20071120 regex instead of strcmp */
|
if( (!sub && !regexec(&re, str,0 , NULL, 0) ) || /* 20071120 regex instead of strcmp */
|
||||||
(sub && !strcmp(str, val) && !bus) || (sub && strstr(str,val) && bus))
|
(sub && !strcmp(str, val) && !bus) || (sub && strstr(str,val) && bus))
|
||||||
#else
|
#else
|
||||||
if( !sub && (strstr(str,val) ) ||
|
|
||||||
|
if( (!sub && win_regexec(NULL, val, str)) ||
|
||||||
(sub && !strcmp(str, val) && !bus) || (sub && strstr(str,val) && bus))
|
(sub && !strcmp(str, val) && !bus) || (sub && strstr(str,val) && bus))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
|
@ -683,7 +698,9 @@ int search(const char *tok, const char *val, int sub, int sel)
|
||||||
if( (!regexec(&re, str,0 , NULL, 0) && !sub ) || /* 20071120 regex instead of strcmp */
|
if( (!regexec(&re, str,0 , NULL, 0) && !sub ) || /* 20071120 regex instead of strcmp */
|
||||||
( !strcmp(str, val) && sub ) )
|
( !strcmp(str, val) && sub ) )
|
||||||
#else
|
#else
|
||||||
if (!strcmp(str, val) && sub)
|
if( (win_regexec(NULL, val, str) && !sub ) || /* 20071120 regex instead of strcmp */
|
||||||
|
( !strcmp(str, val) && sub ) )
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if(!sel) {
|
if(!sel) {
|
||||||
|
|
@ -712,7 +729,8 @@ int search(const char *tok, const char *val, int sub, int sel)
|
||||||
if( (!regexec(&re, str,0 , NULL, 0) && !sub ) ||
|
if( (!regexec(&re, str,0 , NULL, 0) && !sub ) ||
|
||||||
( !strcmp(str, val) && sub ))
|
( !strcmp(str, val) && sub ))
|
||||||
#else
|
#else
|
||||||
if ((!strcmp(str, val) && sub))
|
if( (win_regexec(NULL, val, str) && !sub ) ||
|
||||||
|
( !strcmp(str, val) && sub ))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if(sel==1) {
|
if(sel==1) {
|
||||||
|
|
@ -738,7 +756,8 @@ int search(const char *tok, const char *val, int sub, int sel)
|
||||||
if( (!regexec(&re, str,0 , NULL, 0) && !sub ) ||
|
if( (!regexec(&re, str,0 , NULL, 0) && !sub ) ||
|
||||||
( !strcmp(str, val) && sub ))
|
( !strcmp(str, val) && sub ))
|
||||||
#else
|
#else
|
||||||
if ((!strcmp(str, val) && sub))
|
if( (win_regexec(NULL, val, str) && !sub ) ||
|
||||||
|
( !strcmp(str, val) && sub ))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if(sel==1) {
|
if(sel==1) {
|
||||||
|
|
|
||||||
23
src/save.c
23
src/save.c
|
|
@ -3194,8 +3194,11 @@ int load_sym_def(const char *name, FILE *embed_fd)
|
||||||
/* not found: try web URL */
|
/* not found: try web URL */
|
||||||
if( strstr(xctx->current_dirname, "http://") == xctx->current_dirname ||
|
if( strstr(xctx->current_dirname, "http://") == xctx->current_dirname ||
|
||||||
strstr(xctx->current_dirname, "https://") == xctx->current_dirname) {
|
strstr(xctx->current_dirname, "https://") == xctx->current_dirname) {
|
||||||
tclvareval("try_download_url {", xctx->current_dirname, "} {", name, "}", NULL);
|
|
||||||
my_snprintf(sympath, S(sympath), "%s/xschem_web/%s", tclgetvar("XSCHEM_TMP_DIR"), get_cell_w_ext(name, 0));
|
my_snprintf(sympath, S(sympath), "%s/xschem_web/%s", tclgetvar("XSCHEM_TMP_DIR"), get_cell_w_ext(name, 0));
|
||||||
|
if((lcc[level].fd=fopen(sympath,fopen_read_mode))==NULL) {
|
||||||
|
/* not already cached in .../xschem_web/ so download */
|
||||||
|
tclvareval("try_download_url {", xctx->current_dirname, "} {", name, "}", NULL);
|
||||||
|
}
|
||||||
lcc[level].fd=fopen(sympath,fopen_read_mode);
|
lcc[level].fd=fopen(sympath,fopen_read_mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4101,24 +4104,22 @@ void descend_symbol(void)
|
||||||
load_schematic(1, name_embedded, 1, 1);
|
load_schematic(1, name_embedded, 1, 1);
|
||||||
} else {
|
} else {
|
||||||
char *sympath = NULL;
|
char *sympath = NULL;
|
||||||
my_strdup2(_ALLOC_ID_, &sympath, name);
|
|
||||||
my_strdup2(_ALLOC_ID_, &sympath, abs_sym_path(tcl_hook2(sympath), ""));
|
|
||||||
unselect_all(1);
|
unselect_all(1);
|
||||||
remove_symbols(); /* must follow save (if) embedded */
|
remove_symbols(); /* must follow save (if) embedded */
|
||||||
dbg(1, "name=%s, sympath=%s\n", name, sympath);
|
|
||||||
|
|
||||||
if( stat(sympath, &buf) && /* file does not exists ... */
|
if( /* ... we are in a schematic downloaded from web ... */
|
||||||
/* ... and we are in a schematic downloaded from web ... */
|
|
||||||
(strstr(xctx->current_dirname, "http://") == xctx->current_dirname ||
|
(strstr(xctx->current_dirname, "http://") == xctx->current_dirname ||
|
||||||
strstr(xctx->current_dirname, "https://") == xctx->current_dirname)) {
|
strstr(xctx->current_dirname, "https://") == xctx->current_dirname)) {
|
||||||
/* symbols have already been downloaded while loading parent schematic: set local file path */
|
/* symbols have already been downloaded while loading parent schematic: set local file path */
|
||||||
my_mstrcat(_ALLOC_ID_, &sympath, tclgetvar("XSCHEM_TMP_DIR"),
|
my_mstrcat(_ALLOC_ID_, &sympath, tclgetvar("XSCHEM_TMP_DIR"),
|
||||||
"/xschem_web/", get_cell_w_ext(name, 0), NULL);
|
"/xschem_web/", get_cell_w_ext(tcl_hook2(name), 0), NULL);
|
||||||
load_schematic(1, sympath, 1, 1);
|
|
||||||
} else {
|
|
||||||
dbg(1, "descend_symbol(): sympath=%s\n", sympath);
|
|
||||||
load_schematic(1, sympath, 1, 1);
|
|
||||||
}
|
}
|
||||||
|
if(stat(sympath, &buf)) { /* not found */
|
||||||
|
dbg(1, "descend_symbol: not found: %s\n", sympath);
|
||||||
|
my_strdup2(_ALLOC_ID_, &sympath, abs_sym_path(tcl_hook2(name), ""));
|
||||||
|
}
|
||||||
|
dbg(1, "descend_symbol(): name=%s, sympath=%s, dirname=%s\n", name, sympath, xctx->current_dirname);
|
||||||
|
load_schematic(1, sympath, 1, 1);
|
||||||
my_free(_ALLOC_ID_, &sympath);
|
my_free(_ALLOC_ID_, &sympath);
|
||||||
}
|
}
|
||||||
zoom_full(1, 0, 1, 0.97);
|
zoom_full(1, 0, 1, 0.97);
|
||||||
|
|
|
||||||
|
|
@ -3611,12 +3611,7 @@ proc property_search {} {
|
||||||
button .dialog.but.cancel -text Cancel -command { set search_found 1; destroy .dialog }
|
button .dialog.but.cancel -text Cancel -command { set search_found 1; destroy .dialog }
|
||||||
|
|
||||||
# Window doesn't support regular expression, has to be exact match for now
|
# Window doesn't support regular expression, has to be exact match for now
|
||||||
if {$OS == "Windows"} {
|
checkbutton .dialog.but.sub -text Exact_search -variable search_exact
|
||||||
set search_exact 1
|
|
||||||
checkbutton .dialog.but.sub -text Exact_search -variable search_exact -state disable
|
|
||||||
} else {
|
|
||||||
checkbutton .dialog.but.sub -text Exact_search -variable search_exact
|
|
||||||
}
|
|
||||||
radiobutton .dialog.but.nosel -text {Highlight} -variable search_select -value 0
|
radiobutton .dialog.but.nosel -text {Highlight} -variable search_select -value 0
|
||||||
radiobutton .dialog.but.sel -text {Select} -variable search_select -value 1
|
radiobutton .dialog.but.sel -text {Select} -variable search_select -value 1
|
||||||
# 20171211 added unselect
|
# 20171211 added unselect
|
||||||
|
|
@ -6440,12 +6435,8 @@ if {$OS == "Windows"} {
|
||||||
|
|
||||||
# Remove temporary location for web objects
|
# Remove temporary location for web objects
|
||||||
if {[file exists ${XSCHEM_TMP_DIR}/xschem_web] } {
|
if {[file exists ${XSCHEM_TMP_DIR}/xschem_web] } {
|
||||||
foreach file [glob -nocomplain ${XSCHEM_TMP_DIR}/xschem_web/* ${XSCHEM_TMP_DIR}/xschem_web/.*] {
|
# -force deletes also if not empty
|
||||||
# skip /${XSCHEM_TMP_DIR}/xschem_web/.. and /${XSCHEM_TMP_DIR}/xschem_web/.
|
file delete -force ${XSCHEM_TMP_DIR}/xschem_web
|
||||||
if {[regexp {/\.\.$} $file] || [regexp {/\.$} $file] } {continue}
|
|
||||||
file delete $file
|
|
||||||
}
|
|
||||||
file delete ${XSCHEM_TMP_DIR}/xschem_web
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# used in C code
|
# used in C code
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ L 4 30 -0 40 -0 {}
|
||||||
B 5 37.5 -2.5 42.5 2.5 {name=y dir=out }
|
B 5 37.5 -2.5 42.5 2.5 {name=y dir=out }
|
||||||
B 5 -42.5 -2.5 -37.5 2.5 {name=a dir=in }
|
B 5 -42.5 -2.5 -37.5 2.5 {name=a dir=in }
|
||||||
A 4 25 -0 5 180 360 {}
|
A 4 25 -0 5 180 360 {}
|
||||||
T {$arg1 $rout } -47.5 24 0 0 0.3 0.3 {}
|
T {$arg1 $rout} -47.5 24 0 0 0.3 0.3 {}
|
||||||
T {@name} 25 -22 0 0 0.2 0.2 {}
|
T {@name} 25 -22 0 0 0.2 0.2 {}
|
||||||
T {y} 7.5 -6.5 0 1 0.2 0.2 {}
|
T {y} 7.5 -6.5 0 1 0.2 0.2 {}
|
||||||
T {a} -17.5 -6.5 0 0 0.2 0.2 {}
|
T {a} -17.5 -6.5 0 0 0.2 0.2 {}
|
||||||
|
|
@ -45,7 +45,7 @@ L 4 -20 -20 -20 20 {}
|
||||||
L 4 -20 20 20 0 {}
|
L 4 -20 20 20 0 {}
|
||||||
B 5 37.5 -2.5 42.5 2.5 {name=y dir=out }
|
B 5 37.5 -2.5 42.5 2.5 {name=y dir=out }
|
||||||
B 5 -42.5 -2.5 -37.5 2.5 {name=a dir=in }
|
B 5 -42.5 -2.5 -37.5 2.5 {name=a dir=in }
|
||||||
T {$arg1 $rout } -47.5 24 0 0 0.3 0.3 {}
|
T {$arg1 $rout} -47.5 24 0 0 0.3 0.3 {}
|
||||||
T {@name} 25 -22 0 0 0.2 0.2 {}
|
T {@name} 25 -22 0 0 0.2 0.2 {}
|
||||||
T {y} 7.5 -6.5 0 1 0.2 0.2 {}
|
T {y} 7.5 -6.5 0 1 0.2 0.2 {}
|
||||||
T {a} -17.5 -6.5 0 0 0.2 0.2 {}
|
T {a} -17.5 -6.5 0 0 0.2 0.2 {}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue