FREAD may do be doing undocumented feature

Post Reply
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

FREAD may do be doing undocumented feature

Post 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 ?
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Re: FREAD may do be doing undocumented feature

Post 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 ?
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Re: FREAD may do be doing undocumented feature

Post by jacotton »

SO, the answer is yes.
Use fnctl
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: FREAD may do be doing undocumented feature

Post by dom »

If you add “b” to the fopen mode, so “rb“ then reading should be verbatim and quicker.
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Re: FREAD may do be doing undocumented feature

Post by jacotton »

Ah yes. Use the binary read mode. I used to know that.
tnx
Post Reply