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.

Once the message loop is running the program does this to see if there's anything to be piped into it from the command line:

  IF ParamCount = 0 THEN BEGIN          (* Case (1) or (2) *)
    debug('No parameters (case 1 or 2)');
    TRY
      AssignFile(input, '');            (* Standard input               *)
{ IOCHECKS OFF }
      Reset(input);
{ IOCHECKS ON }
      debug('Reset() -> ' + IntToStr(IOResult));
      TRY
        IF modifiedEof(input) THEN BEGIN (* Case (1)    *)
          debug('At EOF (case 1)');

where

  FUNCTION modifiedEof(VAR f: TEXT): BOOLEAN;

  BEGIN
(*$IFDEF UNIX   *)
    IF IsATTY(f) = 0 THEN BEGIN
      debug('stdin is not a TTY');
{$IOCHECKS OFF }
      RESULT:= Eof(f);
{$IOCHECKS ON }
      debug('Eof() -> ' + IntToStr(IOResult))
    END ELSE BEGIN
      debug('stdin is a TTY');
      RESULT:= TRUE
    END;
(*$ELSE         *)
{ IOCHECKS OFF }
    RESULT:= Eof(f);
{ IOCHECKS ON }
    debug('Eof() -> ' + IntToStr(IOResult))
(*$ENDIF        *)
  END { modifiedEof } ;

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>

I think that I've managed to eliminate all code changes, i.e. I don't think there's anything in a .pas file that's causing the problem. The one thing that did happen however was that r2 got modified by a later version of Lazarus than I usually allow near this program, so I had to back out of various SynEdit (etc.) properties that it had added to the forms.

Is there anything stored in non-Pascal files that could cause this sort of problem?

Alternatively, does Windows have anything equivalent to IsATTY() or Do_IsDevice() that I could use as a guard around the failing Eof()?

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

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

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to