Page 1 of 1

FREAD may do be doing undocumented feature

Posted: Sat Oct 23, 2021 4:19 am
by jacotton
I notice while debugging my toupper code that there is a problem with how fread is working.

It seems to be stripping out the 0x0d characters. The document says its a direct i/o function
and the I see the fgets is processing the string as expected.

Am I getting this wrong ?

Re: FREAD may do be doing undocumented feature

Posted: Sat Oct 23, 2021 4:33 am
by jacotton
Digging into the libsrc ./libsrc/stdio/fread.c
I see that fgetc is used by both z80 and 8080 code paths.

line 132 of fgetc filters 0x0d.

Is there a way to read file data in binary mode ?

Re: FREAD may do be doing undocumented feature

Posted: Sat Oct 23, 2021 4:37 am
by jacotton
SO, the answer is yes.
Use fnctl

Re: FREAD may do be doing undocumented feature

Posted: Sat Oct 23, 2021 7:41 am
by dom
If you add “b” to the fopen mode, so “rb“ then reading should be verbatim and quicker.

Re: FREAD may do be doing undocumented feature

Posted: Sat Oct 23, 2021 4:06 pm
by jacotton
Ah yes. Use the binary read mode. I used to know that.
tnx