[Lazarus] Getting eof from standard input

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Sun Dec 16 16:43:54 CET 2012


Sven Barth wrote:
> On 15.12.2012 18:50, Mark Morgan Lloyd wrote:
>> I've got a program here which works fine on Linux but has started to
>> fail on Windows after running fine for years. This doesn't appear to
>> depend on the version of Lazarus, version of FPC or version of Windows,
>> but since I've now got the source in local svn I can see that the
>> earliest version I checked in (r1) works while the next one (r2) doesn't.
> [...]
>>
>> This used to work, but what I'm now seeing is that when running on
>> Windows it hangs at that Eof() until it sees ^Z<cr>
>>
> You *could* try to set CtrlZMarksEof to False (which is set to True for 
> Windows), but I don't know whether that will really help you...

I've just tried pushing it both ways to no avail.

>> Alternatively, does Windows have anything equivalent to IsATTY() or
>> Do_IsDevice() that I could use as a guard around the failing Eof()?
>>
> There is no IsATTY function for Windows, but a Do_IsDevice exists 
> (internal to the RTL) which basically checks whether the handle stored 
> in the file rec is one of the three I/O handles (StdInputHandle, 
> StdOutputHandle or StdErrorHandle).

I was aware of that from the discussion circa 2005 which pointed me at 
IsATTY(), but had mistakenly noted it as Dos_IsDevice() and for that and 
other reasons didn't realise that it was fully-implemented across all 
platforms. I see it now and can see how it's implemented, if I can't do 
something with that I'll just live with always having to have a dummy 
parameter on Windows.

Also relevant discussion around 
http://lists.freepascal.org/lists/fpc-devel/2006-May/007794.html

I remain perplexed as to where this problem is lurking. If there's the 
potential for trouble caused by e.g. inconsistencies between a .lfm and 
.lrs I might not be the only person this bites.

Many thanks for the suggestions.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]




More information about the Lazarus mailing list