Re: [Radiance-dev] Pipe problems on Windows

2016-03-26 Thread Gregory J. Ward
I agree this is probably not the error we have seen before, though it is an important one. We might think about writing an fgets() replacement for Windows, rather than using fgetline(), which has slightly different semantics. We should replace it at the library level, so it will propagate to a

Re: [Radiance-dev] Pipe problems on Windows

2016-03-26 Thread Georg Mischler
It looks like we're dealing with a broken fgets() included with Visual Studio 2015 Community edition. When a newline character falls exactly to the end of the pipe buffer, it will be ignored. This means that instead of "\t1328\n" the received string will be "\t1328\t1329\n". Any time that happens

Re: [Radiance-dev] Pipe problems on Windows

2016-03-26 Thread Randolph M. Fritz
It seems that Windows fread() sometimes returns a short record when reading from a pipe. See https://github.com/jmacd/xdelta/issues/101#issuecomment-85332549. I still don't understand rcalc's behavior; it seems to me like the short record should be treated as EOF, but maybe I'm missing something.

Re: [Radiance-dev] Pipe problems on Windows

2016-03-26 Thread Gregory J. Ward
It only calls fgets() when the input is ASCII, as it is in the case of reading from cnt. I do call fread() for loading binary input. -G > From: "Randolph M. Fritz" > Subject: Re: [Radiance-dev] Pipe problems on Windows > Date: March 26, 2016 11:48:18 AM PDT > > Maybe we should change that to

Re: [Radiance-dev] Pipe problems on Windows

2016-03-26 Thread Randolph M. Fritz
Maybe we should change that to fread()? fgets() is text-oriented. -- Randolph M. Fritz, Lighting Design and Simulation +1 206 659-8617 || rmfri...@gmail.com On Sat, Mar 26, 2016 at 8:33 AM, Gregory J. Ward wrote: > Input is read from stdin by rcalc using this line in getinputrec(): > >

Re: [Radiance-dev] Pipe problems on Windows

2016-03-26 Thread Gregory J. Ward
Input is read from stdin by rcalc using this line in getinputrec(): return(fgets(inpbuf, INBSIZ, fp) != NULL); I don't know why fgets() would fail on a pipe of ASCII data, but it sounds like that's what is happening in some cases. -Greg > From: Georg Mischler > Subject: Re: [Radiance-

Re: [Radiance-dev] Pipe problems on Windows

2016-03-26 Thread Georg Mischler
Am 2016-03-26 08:27, schrieb Randolph Fritz: On Mar 26, 2016, at 12:09 AM, Georg Mischler wrote: I tend to agree with Randolph. This is likely a problem that comes to the surface due to the different memory layout applied by the MS compiler. I suppose it could also be a timing problem. Perha

Re: [Radiance-dev] Pipe problems on Windows

2016-03-26 Thread Randolph Fritz
On Mar 26, 2016, at 12:09 AM, Georg Mischler wrote: > > I tend to agree with Randolph. This is likely a problem that comes to > the surface due to the different memory layout applied by the MS > compiler. I suppose it could also be a timing problem. Perhaps the Windows stdio library is multi-th

Re: [Radiance-dev] Pipe problems on Windows

2016-03-26 Thread Georg Mischler
Turns out the GitHub console brings a nice set of unix utilities. The tee-d output of cnt is correct in all tested cases. Reading that file via filename argument in rcalc gives the correct output again. Feeding the same data via a pipe from cat causes rcalc to exhibit the bug. So it's definitively

Re: [Radiance-dev] Pipe problems on Windows

2016-03-26 Thread Georg Mischler
No problems with the gcc binaries on Windows either. I tend to agree with Randolph. This is likely a problem that comes to the surface due to the different memory layout applied by the MS compiler. So far it only fails when cnt and rcalc are directly connected via a pipe. When cnt writes to a fi