file_chooser: by default include level 0 base directories even if not containing xschem files; fixed a bug in table_read() (uninitialized data if failed to find table file)
This commit is contained in:
parent
7c8988407d
commit
169f5c9d5f
14
src/save.c
14
src/save.c
|
|
@ -1240,8 +1240,8 @@ int extra_rawfile(int what, const char *file, const char *type, double sweep1, d
|
|||
save = xctx->raw;
|
||||
xctx->raw = NULL;
|
||||
read_ret = table_read(f);
|
||||
my_strdup(_ALLOC_ID_, &xctx->raw->sim_type, type);
|
||||
if(read_ret) {
|
||||
my_strdup(_ALLOC_ID_, &xctx->raw->sim_type, type);
|
||||
xctx->extra_raw_arr[xctx->extra_raw_n] = xctx->raw;
|
||||
xctx->extra_prev_idx = xctx->extra_idx;
|
||||
xctx->extra_idx = xctx->extra_raw_n;
|
||||
|
|
@ -1500,18 +1500,18 @@ int table_read(const char *f)
|
|||
dbg(0, "table_read(): must clear current data file before loading new\n");
|
||||
return 0;
|
||||
}
|
||||
xctx->raw = my_calloc(_ALLOC_ID_, 1, sizeof(Raw));
|
||||
raw = xctx->raw;
|
||||
raw->level = -1;
|
||||
raw->annot_p = -1;
|
||||
raw->annot_sweep_idx = -1;
|
||||
|
||||
/* quick inspect file and get upper bound of number of data lines */
|
||||
ufd = open(f, O_RDONLY);
|
||||
if(ufd < 0) goto err;
|
||||
count_lines_bytes(ufd, &lines, &bytes);
|
||||
close(ufd);
|
||||
|
||||
xctx->raw = my_calloc(_ALLOC_ID_, 1, sizeof(Raw));
|
||||
raw = xctx->raw;
|
||||
raw->level = -1;
|
||||
raw->annot_p = -1;
|
||||
raw->annot_sweep_idx = -1;
|
||||
|
||||
int_hash_init(&raw->table, HASHSIZE);
|
||||
fd = my_fopen(f, fopen_read_mode);
|
||||
if(fd) {
|
||||
|
|
|
|||
|
|
@ -4962,7 +4962,12 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}}
|
|||
# if paths empty use XSCHEM_LIBRARY_PATH list.
|
||||
# 'levels' is set to the number of levels to descend into.
|
||||
# 'level' is used internally by the function and should not be set.
|
||||
proc get_list_of_dirs_with_files {{paths {}} {levels -1} {ext {\.(sch|sym)$}} {level -1}} {
|
||||
# incl_base_levels: if set to 1 always include level 0 dirs
|
||||
proc get_list_of_dirs_with_files {{paths {}} {levels -1} \
|
||||
{ext {\.(sch|sym)$}} \
|
||||
{level -1} \
|
||||
{incl_base_levels 1} \
|
||||
} {
|
||||
# puts "get_list_of_dirs_with_files paths=$paths"
|
||||
global pathlist
|
||||
set dir_with_symbols {}
|
||||
|
|
@ -4973,14 +4978,16 @@ proc get_list_of_dirs_with_files {{paths {}} {levels -1} {ext {\.(sch|sym)$}}
|
|||
# puts "dir:$i"
|
||||
set filelist [glob -nocomplain -directory $i -type f *]
|
||||
set there_are_symbols 0
|
||||
foreach f $filelist {
|
||||
if {[regexp $ext $f]} {
|
||||
# puts "match: $f"
|
||||
set there_are_symbols 1
|
||||
break
|
||||
if {$incl_base_levels == 0 || $level > 0} {
|
||||
foreach f $filelist {
|
||||
if {[regexp $ext $f]} {
|
||||
# puts "match: $f"
|
||||
set there_are_symbols 1
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if {$there_are_symbols} {
|
||||
if {($incl_base_levels && $level == 0) || $there_are_symbols} {
|
||||
lappend dir_with_symbols $i
|
||||
}
|
||||
set dirlist [lsort -dictionary [glob -nocomplain -directory $i -type d *]]
|
||||
|
|
|
|||
Loading…
Reference in New Issue