diff --git a/src/spice_netlist.c b/src/spice_netlist.c index 68895cea..d0cb80ce 100644 --- a/src/spice_netlist.c +++ b/src/spice_netlist.c @@ -47,6 +47,7 @@ void hier_psprint(char **res, int what) /* netlister driver */ char *subckt_name; char filename[PATH_MAX]; char *abs_path = NULL; + struct stat buf; Str_hashtable subckt_table = {NULL, 0}; if((what & 1) && !ps_draw(1)) return; /* prolog */ @@ -87,17 +88,19 @@ void hier_psprint(char **res, int what) /* netlister driver */ { str_hash_lookup(&subckt_table, subckt_name, "", XINSERT); get_sch_from_sym(filename, xctx->sym + i); - /* for printing we go down to bottom regardless of spice_stop attribute */ - load_schematic(1,filename, 0, 1); - zoom_full(0, 0, 1, 0.97); - if(what & 1) ps_draw(2); /* page */ - if(what & 2) { /* print cellname */ - my_strcat(_ALLOC_ID_, res, hier_psprint_mtime(xctx->sch[xctx->currsch])); - my_strcat(_ALLOC_ID_, res, " {"); - my_strcat(_ALLOC_ID_, res, xctx->sch[xctx->currsch]); - my_strcat(_ALLOC_ID_, res, "}\n"); + if(!stat(filename, &buf)) { + /* for printing we go down to bottom regardless of spice_stop attribute */ + load_schematic(1,filename, 0, 1); + zoom_full(0, 0, 1, 0.97); + if(what & 1) ps_draw(2); /* page */ + if(what & 2) { /* print cellname */ + my_strcat(_ALLOC_ID_, res, hier_psprint_mtime(xctx->sch[xctx->currsch])); + my_strcat(_ALLOC_ID_, res, " {"); + my_strcat(_ALLOC_ID_, res, xctx->sch[xctx->currsch]); + my_strcat(_ALLOC_ID_, res, "}\n"); + } + dbg(1,"--> %s\n", skip_dir( xctx->sch[xctx->currsch]) ); } - dbg(1,"--> %s\n", skip_dir( xctx->sch[xctx->currsch]) ); } } } diff --git a/src/xschem.tcl b/src/xschem.tcl index 4a2e8057..3a8393c0 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -1255,33 +1255,33 @@ proc bespice_getdata {sock} { proc xschem_getdata {sock} { global xschem_server_getdata tclcmd_puts - if {[eof $sock] || [catch {gets $sock xschem_server_getdata(line,$sock)}]} { - close $sock ;# close due to client shutdown - puts "Close $xschem_server_getdata(addr,$sock)" - unset xschem_server_getdata(addr,$sock) - unset xschem_server_getdata(line,$sock) - unset xschem_server_getdata(res,$sock) - } else { - puts "tcp<-- $xschem_server_getdata(line,$sock)" - # xschem command must be executed at global scope... - redef_puts - uplevel #0 [list catch $xschem_server_getdata(line,$sock) tclcmd_puts] - rename puts {} - rename ::tcl::puts puts - puts "tcp--> $tclcmd_puts" - if {![regexp {\n$} $tclcmd_puts]} { - set xschem_server_getdata(res,$sock) "$tclcmd_puts\n" + + while {1} { + if {[gets $sock line] < 0} { + break } else { - set xschem_server_getdata(res,$sock) "$tclcmd_puts" + append xschem_server_getdata(line,$sock) $line \n } - puts -nonewline $sock "$xschem_server_getdata(res,$sock)" - flush $sock - close $sock ;# server closes - puts "Close $xschem_server_getdata(addr,$sock)" - unset xschem_server_getdata(addr,$sock) - unset xschem_server_getdata(line,$sock) - unset xschem_server_getdata(res,$sock) } + puts "tcp<-- $xschem_server_getdata(line,$sock)" + # xschem command must be executed at global scope... + redef_puts + uplevel #0 [list catch $xschem_server_getdata(line,$sock) tclcmd_puts] + rename puts {} + rename ::tcl::puts puts + puts "tcp--> $tclcmd_puts" + if {![regexp {\n$} $tclcmd_puts]} { + set xschem_server_getdata(res,$sock) "$tclcmd_puts\n" + } else { + set xschem_server_getdata(res,$sock) "$tclcmd_puts" + } + puts -nonewline $sock "$xschem_server_getdata(res,$sock)" + flush $sock + close $sock ;# server closes + puts "Close $xschem_server_getdata(addr,$sock)" + unset xschem_server_getdata(addr,$sock) + unset xschem_server_getdata(line,$sock) + unset xschem_server_getdata(res,$sock) } proc bespice_server {sock addr port} { @@ -1295,12 +1295,12 @@ proc bespice_server {sock addr port} { } } - proc xschem_server {sock addr port} { global xschem_server_getdata puts "Accept $sock from $addr port $port" - fconfigure $sock -buffering line + fconfigure $sock -buffering line -blocking 0 set xschem_server_getdata(addr,$sock) [list $addr $port] + set xschem_server_getdata(line,$sock) {} fileevent $sock readable [list xschem_getdata $sock] }