fix various regressions: escape the ? pattern in awk, be more selective in ? node multiplicity tag recognition in spice.awk, yet some more fixes in abs_sym_path thanks to JL

This commit is contained in:
Stefan Schippers 2020-10-15 13:38:27 +02:00
parent 35f47beca9
commit 4362c44a8d
5 changed files with 37 additions and 25 deletions

View File

@ -1281,7 +1281,7 @@ void get_sym_type(const char *symname, char **type, struct int_hashentry **pinta
else fd=fopen(name,fopen_read_mode);
if(fd==NULL) {
dbg(1, "get_sym_type(): xSymbol not found: %s\n",name);
dbg(1, "get_sym_type(): Symbol not found: %s\n",name);
my_strdup2(1162, type, "");
} else {
char *globalprop=NULL;
@ -1559,7 +1559,7 @@ int load_sym_def(const char *name, FILE *embed_fd)
if(!embed_fd) {
if((lcc[level].fd=fopen(sympath,fopen_read_mode))==NULL)
{
if(recursion_counter == 1) dbg(0, "l_s_d(): xSymbol not found: %s\n",sympath);
if(recursion_counter == 1) dbg(0, "l_s_d(): Symbol not found: %s\n",sympath);
my_snprintf(sympath, S(sympath), "%s/%s.sym", tclgetvar("XSCHEM_SHAREDIR"), "systemlib/missing");
if((lcc[level].fd=fopen(sympath, fopen_read_mode))==NULL)
{

18
src/spice.awk Executable file → Normal file
View File

@ -169,8 +169,8 @@ function process( i, iprefix)
sub("#" iprefix "#", iprefix,$i)
gsub(/,/, "," iprefix,$i)
## 20160301 add '?1' if missing in format string
if(i>1 && ( $(i-1) !~/^?/) ) {
$i = "@1 " $i
if(i>1 && ( $(i-1) !~/^\?/) ) {
$i = "?1 " $i
}
$0 = $0 # reparse input line
}
@ -212,7 +212,7 @@ function process( i, iprefix)
# .probe tran v( ?1 DL[3],DL[2],DL[1],DL[0] , ?1 WL[3],WL{2],WL[1],WL[0] )
if($1 ==".probe" && $4 ~/^?/ && $7 ~/^?/ && NF==9) {
if($1 ==".probe" && $4 ~/^\?[0-9]+$/ && $7 ~/^\?[0-9]+$/ && NF==9) {
num1=split($5,name,",")
num2=split($8,name2,",")
@ -222,7 +222,7 @@ function process( i, iprefix)
}
# .save v( ?1 DL[3],DL[2],DL[1],DL[0] , ?1 WL[3],WL{2],WL[1],WL[0] )
} else if($1 ==".save" && $3 ~/^?/ && $6 ~/^?/ && NF==8) {
} else if($1 ==".save" && $3 ~/^\?[0-9]+$/ && $6 ~/^\?[0-9]+$/ && NF==8) {
num1=split($4,name,",")
num2=split($7,name2,",")
@ -233,13 +233,13 @@ function process( i, iprefix)
# .probe tran v( ?1 LDY1_B[1],LDY1_B[0] )
} else if($1 ==".probe" && $4 ~/^?/ && NF==6) {
} else if($1 ==".probe" && $4 ~/^\?[0-9]+$/ && NF==6) {
num=split($5,name,",")
for(i=1;i<=num;i++) {
print $1 " " $2 " " $3 " " name[i] " " $6
}
# .save v( ?1 LDY1_B[1],LDY1_B[0] )
} else if($1 ==".save" && $3 ~/^?/ && NF==5) {
} else if($1 ==".save" && $3 ~/^\?[0-9]+$/ && NF==5) {
num=split($4,name,",")
for(i=1;i<=num;i++) {
print $1 " " $2 " " name[i] " " $5
@ -277,7 +277,7 @@ function process( i, iprefix)
for(j=2;j<=NF;j+=1) # start from 2 not from 3 20070221
{
if($j ~/^?/) continue # handle the case that $2 not pinlist 20070221
if($j ~/^\?[0-9]+$/) continue # handle the case that $2 not pinlist 20070221
arg_num[j]=split($j,tmp,",")
for(k=1;k<=arg_num[j]; k++) {
arg_name[j,k]=tmp[k]
@ -289,14 +289,14 @@ function process( i, iprefix)
for(j=2;j<=NF;j++)
{
if($j !~ /^?/)
if($j !~ /^\?[0-9]+$/)
{
printf "%s ", $j # if not a node just print it
}
else
{
nmult=$(j++)
sub(/?/,"",nmult)
sub(/\?/,"",nmult)
if(nmult+0==-1) nmult=arg_num[j]
for(l=0;l<nmult+0;l++)
{

4
src/verilog.awk Executable file → Normal file
View File

@ -245,7 +245,7 @@ begin_module && $1 ~/^\);$/ {
{
pin=""
if(j>7) {printf ","}
if($j !~ /^?/)
if($j !~ /^\?[0-9]+$/)
{
pin=pin $j # if not a node just print it
}
@ -253,7 +253,7 @@ begin_module && $1 ~/^\);$/ {
{
nmult=$(j++);j++
sub(/?/,"",nmult)
sub(/\?/,"",nmult)
nmult=nmult+0
if(nmult==-1) nmult=arg_num[j]
for(l=0;l<nmult;l++)

View File

@ -2645,7 +2645,7 @@ proc abs_sym_path {fname {ext {} } } {
set fname [file rootname $fname]$ext
}
if {$::OS == "Windows"} {
if {$::OS eq "Windows"} {
# absolute path: return as is
if { [regexp {^[A-Za-z]\:/} $fname ] } {
return "$fname"
@ -2656,21 +2656,32 @@ proc abs_sym_path {fname {ext {} } } {
return "$fname"
}
}
# transform a/b/../c to a/c or a/b/c/.. to a/b
while {[regsub {[^/]+/\.\./?} $fname {} fname] } {}
if { $::OS ne {Windows}} {
# transform a/b/../c to a/c or a/b/c/.. to a/b
while {[regsub {[^/.]+/\.\./?} $fname {} fname] } {}
}
# remove trailing '/'s to non empty path
regsub {([^/]+)/+$} $fname {\1} fname
# if fname is ../../e/f
# and current_dirname is /a/b/c
# set fname to /a/e/f
set tmpdir $current_dirname
# if fname copy tmpfname is ../../e/f
# and current_dirname copy tmpdirname is /a/b/c
# set tmpfname to /a/e/f
set tmpdirname $current_dirname
set tmpfname $fname
set found 0
while { [regexp {^\.\./} $fname ] } {
while { [regexp {^\.\./} $tmpfname ] } {
set found 1
set tmpdir [file dirname $tmpdir]
regsub {^\.\./} $fname {} fname
set tmpdirname [file dirname $tmpdirname]
regsub {^\.\./} $tmpfname {} tmpfname
}
if {$found } {
if { [regexp {/$} $tmpdirname] } { set tmpfname "${tmpdirname}$tmpfname"
} else { set tmpfname "${tmpdirname}/$tmpfname" }
if { [file exists "$tmpfname"] } { return "$tmpfname" }
## should we return path if directory exists ?
if { $::OS ne {Windows} } {
if { [file exists [file dirname "$tmpfname"]] } { return "$tmpfname" }
}
}
if {$found } {set fname "${tmpdir}/$fname"}
# remove any leading './'
while { [regsub {^\./} $fname {} fname] } {}
# if previous operation left fname empty set to '.'

View File

@ -1,5 +1,6 @@
v {xschem version=2.9.5 file_version=1.1}
v {xschem version=2.9.8 file_version=1.2}
G {}
K {}
V {}
S {}
E {}