On 2022-01-29 15:05, Thorsten Otto via fpc-devel wrote:
On Samstag, 29. Januar 2022 14:55:30 CET Karoly Balogh wrote:

Yes, but changing this is not trivial in platform independent code,

It doesn't have to, if it can be fixed in fpc_readln_end().

Maybe Sven or someone can say more about the Windows analogy, I'm
not familiar there.

Thats something i have to check. Normally win32 should suffer from the
same problem. The C-runtime (MSVCRT) whould handle that, but not the
Windows ReadFile() function. Maybe that is some magic in the console
mode of windows.

This isn't something specific to Atari and Win32, CRLF is equally used for several other targets (starting with the first one implemented in FPC, which is 32-bit DOS with extender, continuing with the second one, OS/2, and several other). The implementation in the previously mentioned include file shared for all FPC targets allows any of CR, LF or CRLF as end of line. You can see that at the end of fpc_readln_end():

   if (prev=#13) then
     { is there also a #10 after it? }
     begin
       if (TextRec(f).BufPtr^[TextRec(f).BufPos]=#10) then
         { yes, skip that one as well }
         inc(TextRec(f).BufPos);
       exit;
     end;

If there's #13 (CR), the implementation just checks whether #10 follows (if so, it skips this character), but it stops reading regardless from the result. Again, there's nothing wrong to be "fixed" here.


Also then I don't understand why it still works and

returns after pressing it 3 times

I don't understand that either ;)

I know absolutely nothing about Atari, but if I should guess, I'd suggest having a look at how does the function gemdos_fread behave in case of console input - does it return individual characters, or does it return the whole line at once (the latter being the case for other FPC targets as far as I know)? Maybe this is something that needs to be handled specifically when reading from devices (i.e. the console in case of Atari) in the implementation of do_read in rtl/atari/sysfile.inc? I don't know whether there's a reasonable debugging possilibity for Atari, but even if there isn't, you can simply compile a program calling gemdos_fread directly for the stdInput handle and check the exact behaviour this way.

Tomas
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to