← Back to team overview

kicad-developers team mailing list archive

Re: Text file open modes


On Wed, 15 Sep 2010, Dick Hollenbeck wrote:

"rt" as the fopen() mode.  Won't that make the fgets() code read in
lines of text without the \r in a platform independent way ?

In your dreams:D the 't' modifier is windows (and msdos) only. By ANSI
specs all letters not understood are ignored so (linux) libc accept it,
i.e. open the file, but opens it in 'binary' mode. OTOH there is a 'b'
letter in the standard to force binary mode (which is ignored too, since
it's always in effect). Since macosx is bsd based I think the same
applies, too.

In effect the meaning of the 't' is 'native text', not 'windows text' so
it does make sense that fopen hasn't a switch for CRLF processing
(otherwise what about, i.e., old macos which was CR only?)

Also I had some fabricators (and tools!) which had the same problem,
refusing LF-only lines (they latch on the CR, maybe...). I don't know if
the gerber specs says something about that (it was a 5-bit baudot paper
tape standard IIRC) but the problem is there; you can only hope that
linux and maybe macos users are smart enough to utod or something the

No doubt gerbview needs a lot of work, and I'm not even sure what's
there is to be considered a good starting point.  I've spent some time
on it, but have always had the feeling I was building on sand.

gerbv is *years* ahead of gerbview...

Lorenzo Marcantonio
Logos Srl

Follow ups