diff --git a/src/save.c b/src/save.c index ad5fb6d6..b735bb5f 100644 --- a/src/save.c +++ b/src/save.c @@ -885,6 +885,12 @@ void read_record(int firstchar, FILE *fp, int dbg_level) { int c; char *str = NULL; + int unget = 1; + + if(firstchar == -1) { + firstchar = fgetc(fp); + unget = 0; + } dbg(dbg_level, "SKIP RECORD\n"); if(firstchar != '{') { dbg(dbg_level, "%c", firstchar); @@ -893,7 +899,7 @@ void read_record(int firstchar, FILE *fp, int dbg_level) if (c=='\r') continue; if(c == '\n') { dbg(dbg_level, "\n"); - ungetc(c, fp); /* so following read_line does not skip next line */ + if(unget) ungetc(c, fp); /* so following read_line does not skip next line */ break; } if(c == '{') { diff --git a/src/xschem.tcl b/src/xschem.tcl index ac40382e..1dd75ccc 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -2040,6 +2040,7 @@ proc is_xschem_file {f} { if {$a} { puts stderr "Can not open file $f" } else { + fconfigure $fd -translation binary while { [gets $fd line] >=0 } { if { [regexp {^[TKGVSE] \{} $line] } { incr score } if { [regexp {^[BL] +[0-9]+ +[-0-9.eE]+ +[-0-9.eE]+ +[-0-9.eE]+ +[-0-9.eE]+ +\{} $line] } {incr score} @@ -2049,7 +2050,7 @@ proc is_xschem_file {f} { set ret 1 } } - if { $score > 6 } { set ret 1} ;# Heuristic decision :-) + if { $score > 4 } { set ret 1} ;# Heuristic decision :-) if { $ret } { if { $instances} { set ret SCHEMATIC